Frequency of MouseMoveEvents lower with Qt 6
-
I'm working on a larger Qt application (OpenBoard), basically for drawing on a QGraphicsView. Some time ago we switched from Qt5 to Qt6. Since then I observed a much lower frequency of MouseMoveEvents. I'm using Linux, but the same was also reported from Windows users. I already did some experiments:
- With Qt5 (actually 5.15.2), the application gets a MouseMoveEvent about every 7ms.
- With Qt6 (actually 6.6.2), the application gets a MouseMoveEvent about every 33ms.
- I made a minimal PoC. Here I actually get the events every 7ms in Qt5 and Qt6.
So it seems it has to do with some operations I have in the event handler. I also measured the time to complete the event processing in OpenBoard: it was between 20 and 60 µs, so much below the mouse event frequency.
So my question is whether there are any known changes between Qt5 and Qt6 which could cause this. Is there any mouse event throttling based on whatever reasons? Any ideas what I could try or test next?
-
@letsfindaway said in Frequency of MouseMoveEvents lower with Qt 6:
Any ideas what I could try or test next?
You coulod try to disable the operations in your event handler one after another until you reach 7ms then you know which part of the event handler code causes this behavior.
-
@jsulm Thanks for your reply and recommendation. Yes, I tried this. I currently have two views attached to a QGraphicsScene. I did the following:
- Disabling the second view: repetition rate goes down to 16 ms.
- Just hiding the second view is sufficient, also 16 ms.
- Disabling the update of the scene (just an QGraphicsEclipseItem's position is moved): repetition rate goes down to 7 ms.
So with just commenting the line
mEraser->setPos(pPoint);
the repetition rate goes to the value I want to have, no matter whether I have one or two views attached.
I also tried to reproduce the issue with my minimal PoC and attached even four views to the scene. But here everything is ok, repetition rate stays at 7 ms.
And I checked CPU usage. But this is low. The main thread never uses more than 25% of a core.
-
Hi,
@letsfindaway said in Frequency of MouseMoveEvents lower with Qt 6:
just an QGraphicsEclipseItem's position is moved
how complex is this item? Are any actions connected to the movement of the ellipse?
-
@Pl45m4 Here is a short video of the application showing the issue:
https://github.com/letsfindaway/OpenBoard/issues/203#issuecomment-2595705681- The rubber is a pixmap cursor using
QCursor
. - The circle is repositioned at each mouseMoveEvent. You see that it is lagging behind the cursor.
- The preview image to the left is the second view attached to the same scene.
So you see, nothing complicated. And as I already said in the beginning: when I run the same program using Qt5, then the lag is much smaller, because the repetition rate of the mouseMoveEvents is higher.
I have
setMouseTracking(true)
, so that I get the events even when the mouse button is not pressed.And no, there are no further actions connected to the movement as long as the mouse button is not pressed.
- The rubber is a pixmap cursor using