<?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[[SOLVED] QKeySequence only for one widget]]></title><description><![CDATA[<p dir="auto">Hello everyone!<br />
I have MainWindow with WebView in it, StatusBar and Subclassed QFrame widget on StatusBar.<br />
in my QFrame widget I create action for key sequence as follow:<br />
@<br />
ExSearchBar::ExSearchBar(QWidget *parent):QFrame(parent)<br />
{</p>
<p dir="auto">.....</p>
<p dir="auto">QKeySequence keys_esc(Qt::Key_Escape);<br />
this-&gt;esc = new QAction(this);<br />
connect(this-&gt;esc, SIGNAL(triggered()), this, SLOT(search_hide()));<br />
this-&gt;esc-&gt;setShortcut(keys_esc);<br />
this-&gt;addAction(this-&gt;esc);<br />
}<br />
@</p>
<p dir="auto">The problem is, what the action triggers even if currently active(focused) widget is WebView(or WebFrame)...<br />
How can I restrict this QKeySequence action only for widget it is created for?(Should be triggered only when widget or its childs are in focus)</p>
<p dir="auto">Thanks in advance!</p>
]]></description><link>https://forum.qt.io/topic/16020/solved-qkeysequence-only-for-one-widget</link><generator>RSS for Node</generator><lastBuildDate>Wed, 23 Sep 2026 20:06:11 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/16020.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 19 Apr 2012 08:43:10 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [SOLVED] QKeySequence only for one widget on Thu, 19 Apr 2012 09:06:13 GMT]]></title><description><![CDATA[<p dir="auto">My bad :) Thank you guys! Works!</p>
]]></description><link>https://forum.qt.io/post/136269</link><guid isPermaLink="true">https://forum.qt.io/post/136269</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Thu, 19 Apr 2012 09:06:13 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] QKeySequence only for one widget on Thu, 19 Apr 2012 09:04:23 GMT]]></title><description><![CDATA[<p dir="auto">you set the shortcutContxt to '<em>WindowShortcut</em>' which is the default, meaning the behaviour shouldn't have changed.</p>
<p dir="auto">Try changing it to 'Qt::<em>WidgetShortcut</em>'.</p>
]]></description><link>https://forum.qt.io/post/136268</link><guid isPermaLink="true">https://forum.qt.io/post/136268</guid><dc:creator><![CDATA[rschaub]]></dc:creator><pubDate>Thu, 19 Apr 2012 09:04:23 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] QKeySequence only for one widget on Thu, 19 Apr 2012 09:00:27 GMT]]></title><description><![CDATA[<p dir="auto">@<br />
ExSearchBar::ExSearchBar(QWidget *parent):QFrame(parent)<br />
{<br />
.....</p>
<p dir="auto">QKeySequence keys_esc(Qt::Key_Escape);<br />
this-&gt;esc = new QAction(this);<br />
connect(this-&gt;esc, SIGNAL(triggered()), this, SLOT(search_hide()));<br />
this-&gt;esc-&gt;setShortcut(keys_esc);<br />
this-&gt;esc-&gt;setShortcutContext(Qt::WindowShortcut);<br />
this-&gt;addAction(this-&gt;esc);<br />
}@</p>
<p dir="auto">Doesn't work... it is still triggered.. . and this-&gt;hasFocus() is false...</p>
]]></description><link>https://forum.qt.io/post/136266</link><guid isPermaLink="true">https://forum.qt.io/post/136266</guid><dc:creator><![CDATA[[[global:former-user]]]]></dc:creator><pubDate>Thu, 19 Apr 2012 09:00:27 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] QKeySequence only for one widget on Thu, 19 Apr 2012 08:53:04 GMT]]></title><description><![CDATA[<p dir="auto">you should set the shortcutContext to 'Qt::WidgetShortcut', which will enable the action only if the widget itself has focus, but not any of its children.</p>
]]></description><link>https://forum.qt.io/post/136263</link><guid isPermaLink="true">https://forum.qt.io/post/136263</guid><dc:creator><![CDATA[rschaub]]></dc:creator><pubDate>Thu, 19 Apr 2012 08:53:04 GMT</pubDate></item><item><title><![CDATA[Reply to [SOLVED] QKeySequence only for one widget on Thu, 19 Apr 2012 08:45:53 GMT]]></title><description><![CDATA[<p dir="auto">Try changing the "shortcut context":<a href="http://qt-project.org/doc/qt-4.8/qaction.html#shortcutContext-prop" target="_blank" rel="noopener noreferrer nofollow ugc">http://qt-project.org/doc/qt-4.8/qaction.html#shortcutContext-prop</a> .</p>
]]></description><link>https://forum.qt.io/post/136261</link><guid isPermaLink="true">https://forum.qt.io/post/136261</guid><dc:creator><![CDATA[d2uriel]]></dc:creator><pubDate>Thu, 19 Apr 2012 08:45:53 GMT</pubDate></item></channel></rss>