<?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[Injecting MouseEvent not working when Window is not focused]]></title><description><![CDATA[<p dir="auto">Hi everyone,</p>
<p dir="auto">I've got a problem wich I don't know how to handle.<br />
I'm trying to inject Mouse event this way : <a class="plugin-mentions-user plugin-mentions-a" href="/user/void">@<bdi>void</bdi></a> Mouse::press ( )<br />
{<br />
QWidget *receiver = QApplication::widgetAt(m_pos);<br />
m_button = Qt::LeftButton;<br />
if (receiver)<br />
{<br />
QMouseEvent *event = new QMouseEvent(QEvent::MouseButtonPress, receiver-&gt;mapFromGlobal(m_pos), m_button, m_button, Qt::NoModifier);<br />
QCoreApplication::postEvent(receiver, event);<br />
}<br />
}<br />
@</p>
<p dir="auto">This work fine when my app has the focus, but I can't make it work when another window has the focus.<br />
I've tried this :<br />
@    // set main window unfocusable<br />
if (l_app_settings.unfocusable)<br />
{<br />
HWND winHandle = (HWND)l_viewer.effectiveWinId();<br />
ShowWindow(winHandle, SW_HIDE);<br />
SetWindowLong(winHandle, GWL_EXSTYLE, GetWindowLong(winHandle, GWL_EXSTYLE)<br />
| WS_EX_NOACTIVATE | WS_EX_APPWINDOW);<br />
ShowWindow(winHandle, SW_SHOW);<br />
}<br />
@</p>
<p dir="auto">This work fine with KeyEvent.<br />
Does anyone have an idea ?</p>
<p dir="auto">Thanks a lot for reading me.<br />
Mokona</p>
]]></description><link>https://forum.qt.io/topic/42476/injecting-mouseevent-not-working-when-window-is-not-focused</link><generator>RSS for Node</generator><lastBuildDate>Sun, 03 May 2026 15:14:19 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/42476.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 12 Jun 2014 14:02:47 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Injecting MouseEvent not working when Window is not focused on Sun, 06 Jul 2014 23:44:56 GMT]]></title><description><![CDATA[<p dir="auto">Actually, this is much like what I am trying to achieve. Qt should have this thing called QToolWindow. So, we make them float, fill them with controls, but when user interact with the controls, the focus won't shifted from the main application window. Which is just like what tool window should behave.</p>
<p dir="auto">I haven' figure out way how to solve this anyway. That WX_EX_NOACTIVATE should've been worked, but I am not sure a proper way to call it. This is my current question in StackOverflow about "this issue":<a href="http://stackoverflow.com/questions/24582525/how-to-show-clickable-qframe-without-loosing-focus-from-main-window?noredirect=1#comment38082228_24582525" target="_blank" rel="noopener noreferrer nofollow ugc">http://stackoverflow.com/questions/24582525/how-to-show-clickable-qframe-without-loosing-focus-from-main-window?noredirect=1#comment38082228_24582525</a>.</p>
]]></description><link>https://forum.qt.io/post/234790</link><guid isPermaLink="true">https://forum.qt.io/post/234790</guid><dc:creator><![CDATA[ekoswibowo]]></dc:creator><pubDate>Sun, 06 Jul 2014 23:44:56 GMT</pubDate></item><item><title><![CDATA[Reply to Injecting MouseEvent not working when Window is not focused on Thu, 12 Jun 2014 21:04:24 GMT]]></title><description><![CDATA[<p dir="auto">Hi and welcome to devnet,</p>
<p dir="auto">Can you explain what you are trying to achieve ?</p>
]]></description><link>https://forum.qt.io/post/231769</link><guid isPermaLink="true">https://forum.qt.io/post/231769</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Thu, 12 Jun 2014 21:04:24 GMT</pubDate></item></channel></rss>