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. Widgets stealing mouse wheel focus from one another.

Widgets stealing mouse wheel focus from one another.

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 525 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.
  • enjoysmathE Offline
    enjoysmathE Offline
    enjoysmath
    wrote on last edited by
    #1

    Here's a video of my app in action and you can see what happens when I mouse wheel:

    https://youtu.be/sxXhrDOx7Co

    I have a FlowLayout:

    https://gist.github.com/Cysu/7461066

    Containing a dynamic list of QGraphicsView widgets essentially. I have zoom capability on the customized QGraphicsViews using the mouseWheelEvent.

    However, as you can see midway through the video, when you mouse wheel and your focused on an editor (view), then the FlowLayout also scrolls.

    So essentially the event is being captured by two handlers. Whereas the desired behavior is that it should only zoom the editor.

    Thanks.

    If it helps, here is the complete source code which is rather clean and easy to navigate:

    https://github.com/enjoysmath/BananaCats

    https://github.com/enjoysmath
    https://math.stackexchange.com/users/26327/exercisingmathematician

    1 Reply Last reply
    0
    • enjoysmathE Offline
      enjoysmathE Offline
      enjoysmath
      wrote on last edited by
      #2

      Solved it with this code added to my FlowLayout:

          widget.removeEventFilter(self)
              
          def addWidget(self, widget):
              widget.installEventFilter(self)
              super().addWidget(widget)
      
          def eventFilter(self, watched, event):
              if event.type() == QEvent.Wheel:
                  event.accept()
                  return True
              return super().eventFilter(watched, event)
      

      https://github.com/enjoysmath
      https://math.stackexchange.com/users/26327/exercisingmathematician

      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