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. Event handling with QGraphicsItems
QtWS25 Last Chance

Event handling with QGraphicsItems

Scheduled Pinned Locked Moved Solved General and Desktop
graphics scenegraphicsitem
3 Posts 1 Posters 752 Views
  • 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.
  • A Offline
    A Offline
    ArsenArsen
    wrote on 15 Jul 2018, 16:29 last edited by
    #1

    Hey there! I am writing a QGraphicsItem implementation that draws and handles a resizable rectangle, and a QGraphicsScene with some code that handles screen area selection. Upon trying to resize the custom item the selection resizes as well. Since I am pretty bad at explaining I've attached a video demonstrating the problematic behaviour. What I would like to happen is that the one which started resizing first would be the only one resizing (that is, if I was to make a different selection the selection would resize and the custom rectangle would ignore it, and if I was to resize the rectangle the selection would stay unaltered). I am wondering is this possible?

    PS: As of right now I have the custom rectangle handling it's own resizing and the scene handling resizing the selection.

    https://i.imgur.com/bwKyE31.mp4

    1 Reply Last reply
    0
    • A Offline
      A Offline
      ArsenArsen
      wrote on 15 Jul 2018, 22:55 last edited by ArsenArsen
      #2

      I've done some debugging and brainstoriming, and I found a way to prevent "corner catching", it's pretty simple, but I have problem where something along the event chain (calling QGraphicsScene::mouseMoveEvent(e)) something accepts the event. That only happens if I am moving my mouse inside the rectangle, outside it events are not accepted.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        ArsenArsen
        wrote on 15 Jul 2018, 23:22 last edited by
        #3

        Solved it: by checking is the cursor in an "interactive" region of the graphics item in QGraphicsItem::mousePressEvent I can determine whether the item will become a mouse grabber (by either accepting or ignoring the event). When it comes to the graphics scene I simply prioritise the event propagation to the selection area resizing and I ignore accepted events.

        1 Reply Last reply
        1

        1/3

        15 Jul 2018, 16:29

        • Login

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