QGraphicsScene resets buttonScenePos when a different button is clicked



  • While moving mouse with button pressed (say LMB) I can get the place where the user started the "drag" with QGraphicsSceneMouseEvent::​buttonDownScenePos(Qt::MouseButton button), like so:
    @mouseEvent->buttonDownScenePos(Qt::LeftButton)@

    But, if during the move the user presses another button (say, RMB) the position gets reset to (0,0).

    Once again: user presses LMB at point X, moves mouse to point Y, buttonDownScenePos(Qt::LeftButton) reports properly, user presses RMB (without releasing RMB), buttonDownScenePos(Qt::LeftButton) returns (0,0).

    My question is: is this a bug in Qt or is it intended? If intended doesn't it at least deserve a note in the documentation?

    I realise that this is painfully easy to work around, but after spending the better half of today looking for this I'd like to know the reason why.

    Note: I'm using Qt 5.2.1
    Note 2: I'm using 5.2.1 because it's the latest in Ubuntu repositories


  • Lifetime Qt Champion

    Hi,

    Can you show the exact code where you are storing the original position ?



  • It's from my day job, under NDA and stuff, so I'll to mock something, but that's rather after new year.

    Anyway, the whole point is I didn't store the original press position, but rather used event argument to get it. Which works fine unless the user presses another mouse button while still holding the first one.


  • Lifetime Qt Champion

    Why not store it ?

    If you take the event when the user presses the RMB after the LMB, it seems logical that the value returned for LMB is 0 since this is a new press event triggered by a different button.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.