[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: Simulate QMenu hover on a QAction?
From:       Matic Kukovec <kukovecmatic () hotmail ! com>
Date:       2021-07-28 9:37:17
Message-ID: VE1PR09MB328064A46AB6D6AC4A75C13AD7EA9 () VE1PR09MB3280 ! eurprd09 ! prod ! outlook ! com
[Download RAW message or body]

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 mouseMo=
veEvent 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@gmail.com>
Sent: Tuesday, July 27, 2021 4:16 PM
To: Matic Kukovec <kukovecmatic@hotmail.com>
Cc: pyqt@riverbankcomputing.com <pyqt@riverbankcomputing.com>
Subject: Re: Simulate QMenu hover on a QAction?

Il giorno mar 27 lug 2021 alle ore 09:33 Matic Kukovec <kukovecmatic@hotmai=
l.com<mailto:kukovecmatic@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 wit=
h 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 ove=
rriding the popup behavior on mouse press.
I suggest you to share a minimal reproducible example so that we could bett=
er understand what's going on.

Maurizio
--
=C8 difficile avere una convinzione precisa quando si parla delle ragioni d=
el cuore. - "Sostiene Pereira", Antonio Tabucchi
http://www.jidesk.net

[Attachment #3 (text/html)]

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} \
</style> </head>
<body dir="ltr">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: \
rgb(0, 0, 0);"> Hello again,</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: \
rgb(0, 0, 0);"> <br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: \
rgb(0, 0, 0);"> For anyone looking at this thread, the problem is that the widgets \
added to the <i> QWidgetAction</i> with <i>.setDefaultWidget<b> consume </b></i>the \
<i>mouseMoveEvent</i>, which needs to be ignored.</div> <div style="font-family: \
Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);"> The solution \
is to enable mouse tracking on all widgets in the added to the <i>QWidgetAction \
</i>with<i> .setMouseTracking(True)</i> and then overriding the <i>mouseMoveEvent \
</i>method and ignoring the event in every widget, like so:</div> <blockquote \
style="margin-top:0;margin-bottom:0"> <div style="font-family: Calibri, Helvetica, \
sans-serif; font-size: 12pt; color: rgb(0, 0, 0);"> <i><span style="font-size: \
10pt;">def mouseMoveEvent(self, event):</span><br> </i></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: \
rgb(0, 0, 0);"> <i><span style="font-size: 10pt;">&nbsp;&nbsp;&nbsp; \
event.ignore()</span></i></div> </blockquote>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: \
rgb(0, 0, 0);"> <br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: \
rgb(0, 0, 0);"> Thanks for the hints</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: \
rgb(0, 0, 0);"> Matic<br>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" \
style="font-size:11pt" color="#000000"><b>From:</b> Maurizio Berti \
&lt;maurizio.berti@gmail.com&gt;<br> <b>Sent:</b> Tuesday, July 27, 2021 4:16 PM<br>
<b>To:</b> Matic Kukovec &lt;kukovecmatic@hotmail.com&gt;<br>
<b>Cc:</b> pyqt@riverbankcomputing.com &lt;pyqt@riverbankcomputing.com&gt;<br>
<b>Subject:</b> Re: Simulate QMenu hover on a QAction?</font>
<div>&nbsp;</div>
</div>
<div>
<div dir="ltr">
<div dir="ltr">Il giorno mar 27 lug 2021 alle ore 09:33 Matic Kukovec &lt;<a \
href="mailto:kukovecmatic@hotmail.com">kukovecmatic@hotmail.com</a>&gt; ha \
scritto:<br> </div>
<div class="x_gmail_quote">
<blockquote class="x_gmail_quote" style="margin:0px 0px 0px 0.8ex; border-left:1px \
solid rgb(204,204,204); padding-left:1ex"> <div dir="ltr">
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; \
color:rgb(0,0,0)"> <span style="font-size:12pt">I just rechecked, and yes, I'm not \
using a QAction, but a QWidgetAction on which I first set a default widget with \
</span><i style="font-size:12pt"><b>setDefaultWidget</b></i><span \
style="font-size:12pt">,</span><br> </div>
<div style="font-family:Calibri,Helvetica,sans-serif; font-size:12pt; \
color:rgb(0,0,0)"> which is a groupbox with a few labels with text/images, then add a \
menu with <b><i>setMenu</i></b>.</div> </div>
</blockquote>
<div><br>
</div>
<div>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,&nbsp;especially if you're \
overriding the popup behavior on mouse press.</div> <div>I suggest you to \
share&nbsp;a minimal reproducible example so that we could better understand \
what's&nbsp;going on.</div> </div>
<div><br>
</div>
<div>Maurizio</div>
-- <br>
<div dir="ltr" class="x_gmail_signature">È difficile avere una convinzione precisa \
quando si parla delle ragioni del cuore. - &quot;Sostiene Pereira&quot;, Antonio \
Tabucchi<br> <a href="http://www.jidesk.net" \
target="_blank">http://www.jidesk.net</a></div> </div>
</div>
</body>
</html>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic