Simulate QMenu hover on a QAction?

Matic Kukovec kukovecmatic at hotmail.com
Wed Jul 28 10:37:17 BST 2021


Hello again,

For anyone looking at this thread, the problem is that the widgets added to the QWidgetAction with .setDefaultWidget consume the mouseMoveEvent, which needs to be ignored.
The solution is to enable mouse tracking on all widgets in the added to the QWidgetAction with .setMouseTracking(True) and then overriding the mouseMoveEvent method and ignoring the event in every widget, like so:
def mouseMoveEvent(self, event):
    event.ignore()

Thanks for the hints
Matic
________________________________
From: Maurizio Berti <maurizio.berti at gmail.com>
Sent: Tuesday, July 27, 2021 4:16 PM
To: Matic Kukovec <kukovecmatic at hotmail.com>
Cc: pyqt at riverbankcomputing.com <pyqt at riverbankcomputing.com>
Subject: Re: Simulate QMenu hover on a QAction?

Il giorno mar 27 lug 2021 alle ore 09:33 Matic Kukovec <kukovecmatic at hotmail.com<mailto:kukovecmatic at hotmail.com>> ha scritto:
I just rechecked, and yes, I'm not using a QAction, but a QWidgetAction on which I first set a default widget with setDefaultWidget,
which is a groupbox with a few labels with text/images, then add a menu with setMenu.

Uhm. I see a QComboBox that shows what appears to be a QMenu instead of the standard popup, so, yes, that could be the issue, especially if you're overriding the popup behavior on mouse press.
I suggest you to share a minimal reproducible example so that we could better understand what's going on.

Maurizio
--
È difficile avere una convinzione precisa quando si parla delle ragioni del cuore. - "Sostiene Pereira", Antonio Tabucchi
http://www.jidesk.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20210728/34591411/attachment.htm>


More information about the PyQt mailing list