[Interest] Keyboard modifiers don't update in QGraphicsSceneMouseEvents

Guido Seifert wargand at gmx.de
Wed Nov 4 19:38:47 CET 2015


Hiya, today I found an interesting problem here:
http://stackoverflow.com/questions/33501376/unexpected-behaviour-with-qmousemoveevent-and-qkeyevent-modifiers/33528494#33528494

A QGraphicsView sends QWheelEvents. These event are used to scale a QGraphicsScene. Looks like the scaling causes the
scene to send QGraphicsSceneMouseEvents of type QGraphicsSceneMouseMove, even though the mouse does not physically move.
Maybe it is because of some relative movement of the mouse pointer due to the scaling? 

But this is not the problem. Even though the QWheelEvents constantly initiate new QGraphicsSceneMouseEvents, the "Qt::KeyboardModifiers QGraphicsSceneMouseEvent::modifiers()" are only updated, when the mouse is moved physically. Without actual mouse movement, the returned 
Qt::KeyboardModifiers do not change.

My proposed workaround to use QApplication::queryKeyboardModifiers() seems to work and is as answer probably good enough. But I find this 
solution a bit unsatisfying when I don't know what causes this problem in the first place. Is above behaviour to be expected, or is it a bug? 
Same behaviour in Qt 4.8.7 and Qt 5.5.1.


Guido
  



More information about the Interest mailing list