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. Propagate mouse event from Widget over QGraphicsView to QGraphicsView

Propagate mouse event from Widget over QGraphicsView to QGraphicsView

Scheduled Pinned Locked Moved Unsolved General and Desktop
qgraphicsviewevent handling
4 Posts 3 Posters 1.2k 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.
  • M Offline
    M Offline
    mchinand
    wrote on 6 Feb 2020, 16:12 last edited by mchinand 2 Jul 2020, 14:37
    #1

    I'm working on a project that has a QWidget (containing a stacked layout with widgets in each stacked Widget) over a QGraphicsView and want mouse events to pass to the QGraphicsView when the event is not over an interactive widget (combobox, button, etc.). For the overlying widgets, I reimplemented the mousePress/Move/Release events with just
    event->ignore()which I thought was supposed to pass the event to its parent. What seems to be happening (observed via GammaRay) is the event goes to the Stacked Widget then to the Widget containing the Stacked Layout (which is a child of the QGraphicsView) but stops there. How do I get it to continue to the QGraphicsView? Adding Qt::WA_TransparentForMouseEventsattribute to the overlying widget prevents any interaction with its child widgets, so that is not a solution for me.

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 6 Feb 2020, 20:42 last edited by
      #2

      Hi,

      Is the widget part of the Graphics View ?

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

      M 1 Reply Last reply 7 Feb 2020, 14:42
      0
      • S SGaist
        6 Feb 2020, 20:42

        Hi,

        Is the widget part of the Graphics View ?

        M Offline
        M Offline
        mchinand
        wrote on 7 Feb 2020, 14:42 last edited by
        #3

        No, it is not. I think the thought was that since the widget was to remain fixed and not move when the view moved, that it should not be part of the scene. Its parent is the QGraphicsView, but it's not an item in the scene.

        1 Reply Last reply
        0
        • A Offline
          A Offline
          Andeol
          wrote on 7 Feb 2020, 16:14 last edited by
          #4

          Probably not the cleanest solution, but a workaround would be to use an eventFilter. The QGraphicsView could call
          widgetName->installEventFilter(this)

          Then in the QGraphicsView, you override the method "eventFilter". That should receive the event originally destined to your widget. Be careful, handling event coordinates can be a bit messy.

          Developer for R++ : https://rplusplus.com/

          1 Reply Last reply
          0

          4/4

          7 Feb 2020, 16:14

          • Login

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