Why the paintevent is not working?
-
Hi, I've created two QDialogs and connect them together by using signal and slot in the main.cpp. What I wish to see is that when I draw a line on the first window, it will be displayed on the second one. I am certain that the signal is accepted by the slot as printPath() is able to print out the path. However, the second window is not updated when I call the update() in setPath(). Why is that?
void Receiver::paintevent(QPaintEvent *e) { QPainter painter(this); painter.drawPath(*path); } void Receiver::setPath(QPainterPath* inPath) { path = inPath; update(); printPath(); } -
It should be
paintEvent, notpaintevent. When overriding virtual members use theoverridekeyword in the header. It will help you catch typos like this.Also, since you're passing the path through a pointer, make sure that path object is still alive when
paintEventis called, otherwise that's undefined behavior.