Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. eventFilter isn't catching QEvent.Enter when the mouse is pressed
Forum Updated to NodeBB v4.3 + New Features

eventFilter isn't catching QEvent.Enter when the mouse is pressed

Scheduled Pinned Locked Moved Solved Qt for Python
3 Posts 1 Posters 430 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.
  • D Offline
    D Offline
    DoubleFelix
    wrote on last edited by
    #1

    I have an array of buttons right next to each other, and I'd like to be able to let the user click one and then drag the mouse to click any other buttons they hover over.

    I have mousePressEvent and mouseReleaseEvent implemented to set a boolean depending on whether or not the mouse is pressed down. This works just fine. I then implemented eventFilter (and I installed it) and I have it filtered like this:

        def eventFilter(self, obj, event):
            if event.type() == QtCore.QEvent.Enter:
                print(obj.objectName())
    

    This should just print the button name when I hover over it, however it doesn't work when the mouse is pressed down. What am I doing wrong here?

    Thanks

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DoubleFelix
      wrote on last edited by
      #3

      I fixed it by using a combination of eventFilter to catch QtCore.QEvent.HoverMove, then I grabbed the QPoint position from that and checked if it was hovering over a widget using my_widget.geometry().contains(QPoint).

      1 Reply Last reply
      0
      • D Offline
        D Offline
        DoubleFelix
        wrote on last edited by
        #2

        I should also note that it also fails if I set widget.enterEvent directly and just print the event. It only prints if the mouse is not pressed.

        1 Reply Last reply
        0
        • D Offline
          D Offline
          DoubleFelix
          wrote on last edited by
          #3

          I fixed it by using a combination of eventFilter to catch QtCore.QEvent.HoverMove, then I grabbed the QPoint position from that and checked if it was hovering over a widget using my_widget.geometry().contains(QPoint).

          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