paintEvent is not called after an update() in mouseMoveEvent

1k views Asked by At

I am using a QAbstractScrollArea and a custom QWidget derivative widget as "the" widget (having sizeHint() overriden).

The application needs to constantly update the QWidget content during mouseMove (kind of a drag, but not exactly, it is a drawing tool to draw lines between objects, thus the mouse cursor needs to change and the line needs to be drawn on the fly).

The application works fine, e.g., I can render the content properly, scrollbars visible, I can manually update the viewport during scrollContentsBy, etc.

However, regardless that I manually fire an update() (or repaint()) call in mouseMoveEvent, the paintEvent will only be called after the "drag" process is over, e.g., the mouseReleaseEvent is fired.

And I'm clueless why this happens. Obviously, if I do the update directly within the mouseMoveEvent, it'll be rejected by QPainter (as I can't instantiate a QPainter within the mouseMoveEvent — Qt drops "paintEngine should no longer be called" when trying to do that).

1

There are 1 answers

1
harsszegi On

Never mix update() with viewport()->update().