Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QGraphicsScene resets buttonScenePos when a different button is clicked
Qt 6.11 is out! See what's new in the release blog

QGraphicsScene resets buttonScenePos when a different button is clicked

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 1.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

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

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          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.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved