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. [SOLVED] Handle mouse press in a QGraphicsScene

[SOLVED] Handle mouse press in a QGraphicsScene

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 922 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
    alanbortu
    wrote on last edited by
    #1

    Hello I am attempting to capture a mouse press in a QGraphicsScene. What I want to do is when a user presses the "Delete Room" button, the application goes into a mode so that when the mouse is clicked (for a second time after the button is pressed, think of it like a "select to delete") it just prints something to the debug.

    Here is a screenshot of the application http://paste.opensuse.org/view/raw/35139719

    I am pretty new to Qt so I am probably missing something here. My instinct was to use signals and slots to change the mode after a button press but I dont know how to capture the mouse within the QGraphicsScene (which is in a QGraphicsView).

    Thank you for any help you can give.

    1 Reply Last reply
    0
    • Q Offline
      Q Offline
      qxoz
      wrote on last edited by
      #2

      You can inherit QGraphicsScene and reimplement mouse events.
      Take a look to "examples":https://qt-project.org/doc/qt-5/examples-graphicsview.html . There you will find many useful solutions.

      1 Reply Last reply
      0
      • A Offline
        A Offline
        alanbortu
        wrote on last edited by
        #3

        Thank you, I have it working now. For anyone who comes across it on google, I just reimplemented @void mousePressEvent(QGraphicsSceneMouseEvent *event);@

        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