eventFilter isn't catching QEvent.Enter when the mouse is pressed
-
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
mousePressEventandmouseReleaseEventimplemented to set a boolean depending on whether or not the mouse is pressed down. This works just fine. I then implementedeventFilter(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
-
I fixed it by using a combination of
eventFilterto catchQtCore.QEvent.HoverMove, then I grabbed theQPointposition from that and checked if it was hovering over a widget usingmy_widget.geometry().contains(QPoint). -
I should also note that it also fails if I set
widget.enterEventdirectly and just print the event. It only prints if the mouse is not pressed. -
I fixed it by using a combination of
eventFilterto catchQtCore.QEvent.HoverMove, then I grabbed theQPointposition from that and checked if it was hovering over a widget usingmy_widget.geometry().contains(QPoint).