<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[How to do something while a QAction in the toolbar is kept pressed?]]></title><description><![CDATA[<p dir="auto">I want to show the user a custom menu that I made while the user presses a QAction button in the toolbar. As soon as the user releases this button, I want the menu to disappear. I am able to handle the menu part, but I am confused about how to manage the pressed and released aspect of the QAction, since QAction does not have these attributes.</p>
<p dir="auto">Just to be clear, I want to do some action when the mouse click is down, and as soon as the mouse click is up, I want to stop that action.</p>
<p dir="auto">Thanks.</p>
]]></description><link>https://forum.qt.io/topic/136915/how-to-do-something-while-a-qaction-in-the-toolbar-is-kept-pressed</link><generator>RSS for Node</generator><lastBuildDate>Sat, 13 Jun 2026 20:58:47 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/136915.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 01 Jun 2022 03:12:54 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to do something while a QAction in the toolbar is kept pressed? on Thu, 02 Jun 2022 06:36:21 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/bigben">@<bdi>BigBen</bdi></a> Also check out <code>eventFilter</code>. Here's a <a href="https://doc.qt.io/qtforpython/PySide6/QtCore/QObject.html?highlight=eventfilter#PySide6.QtCore.PySide6.QtCore.QObject.eventFilter" target="_blank" rel="noopener noreferrer nofollow ugc">link to the documentation</a>.</p>
]]></description><link>https://forum.qt.io/post/716222</link><guid isPermaLink="true">https://forum.qt.io/post/716222</guid><dc:creator><![CDATA[adamhendry]]></dc:creator><pubDate>Thu, 02 Jun 2022 06:36:21 GMT</pubDate></item><item><title><![CDATA[Reply to How to do something while a QAction in the toolbar is kept pressed? on Thu, 02 Jun 2022 03:15:14 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/bigben">@<bdi>BigBen</bdi></a> You can get the QToolButton associated with the QAction using <code>widgetForAction</code> from your <code>QToolBar</code> widget</p>
<h4>Python</h4>
<pre><code class="language-python">toolbar.widgetForAction(your_action)
</code></pre>
<p dir="auto">Otherwise, you could try intercepting <code>mousePressEvent</code> and <code>mouseReleaseEvent</code>.</p>
]]></description><link>https://forum.qt.io/post/716210</link><guid isPermaLink="true">https://forum.qt.io/post/716210</guid><dc:creator><![CDATA[adamhendry]]></dc:creator><pubDate>Thu, 02 Jun 2022 03:15:14 GMT</pubDate></item><item><title><![CDATA[Reply to How to do something while a QAction in the toolbar is kept pressed? on Thu, 02 Jun 2022 02:56:50 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">Thanks for the answer. QToolButton supports menus, but the buttons I have in my toolbar are QAction not QToolButton. Can I add a QToolButton to the toolbar too?<br />
If so, how?</p>
]]></description><link>https://forum.qt.io/post/716208</link><guid isPermaLink="true">https://forum.qt.io/post/716208</guid><dc:creator><![CDATA[BigBen]]></dc:creator><pubDate>Thu, 02 Jun 2022 02:56:50 GMT</pubDate></item><item><title><![CDATA[Reply to How to do something while a QAction in the toolbar is kept pressed? on Wed, 01 Jun 2022 19:24:16 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">QToolButton already supports <a href="https://doc.qt.io/qt-5/qtoolbutton.html#setMenu" target="_blank" rel="noopener noreferrer nofollow ugc">menus</a>.</p>
<p dir="auto">What do you want to achieve with your custom implementation ?</p>
]]></description><link>https://forum.qt.io/post/716186</link><guid isPermaLink="true">https://forum.qt.io/post/716186</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Wed, 01 Jun 2022 19:24:16 GMT</pubDate></item></channel></rss>