PDA

View Full Version : Qt goes slow?



Cucus
18th July 2011, 22:38
Hi,

I'm using a dial to move a robot but the dial doesn't move at the same speed as my mouse so I have some troubles to see a correct movement of the robot (all in a openGL widget).

It's true that the movement of the robot is preceded of a huge amount of calculations and matrix operations. However, in C++ it shouldn't be a problem.

Is it possible to have a bottleneck on the signal/slot communication?

Any other ideas and solutions? Thanks

squidge
18th July 2011, 22:50
It depends how they are connected I would guess. If they are queued and you emit millions of them, then I would say yes.

But it sounds like you need an optimiser.

d_stranz
20th July 2011, 04:43
Hi,
It's true that the movement of the robot is preceded of a huge amount of calculations and matrix operations. However, in C++ it shouldn't be a problem.


Seems to me that this is the source of your problem. Remember that the mouse move event is sent on even the smallest movement of the mouse. So if you are doing the same huge amount of calculations for each tiny mouse movement, then your app is probably unable to respond to the mouse in real time.

I would suggest using a variable to keep track of the difference between some "start" mouse or dial position and the "current" mouse position, and only do the calculation and update the robot position when abs( current - start ) > threshold. Then set start = current, and watch some more. You can adjust the threshold so that on a slower processor, the calculations can still keep up with the mouse movement.

But there will always be a situation in which the user tries to move the mouse too fast, so you could also consider using a timer to avoid doing updates more frequently that is practical.