<?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[[Resolved] How can I set the focus on my application at startup]]></title><description><![CDATA[<p dir="auto">Hi There,</p>
<p dir="auto">I am trying to start an app on linux (or even windows) that when run should have focus and hide the mouse. My program does this ok until I hide the mouse... when I hide the mouse the app no longer gets focus!</p>
<p dir="auto">Here is the code:</p>
<p dir="auto">@<br />
#include &lt;QApplication&gt;<br />
#include &lt;QThread&gt;<br />
#include &lt;stdlib.h&gt;</p>
<p dir="auto">int main(int argc, char *argv[])<br />
{<br />
// Create the app<br />
QApplication app(argc, argv);</p>
<pre><code>// Hide the pointer - IF I UN-COMMENT THIS I LOSE FOCUS AT STARTUP.
//app.setOverrideCursor( QCursor( Qt::BlankCursor ) );

// Create main window
MainWindow *window = new MainWindow;

// Set up the UI and execute the App
window-&gt;show();
app.exec&amp;#40;&amp;#41;;

// tidy up
delete(window);
return 0;
</code></pre>
<p dir="auto">}<br />
@</p>
<p dir="auto">You can see my comment where if I un-comment my code to hide the mouse then when the app starts it does not have focus....</p>
<p dir="auto">What do I need to do here?<br />
Thanks</p>
]]></description><link>https://forum.qt.io/topic/34747/resolved-how-can-i-set-the-focus-on-my-application-at-startup</link><generator>RSS for Node</generator><lastBuildDate>Mon, 11 May 2026 11:37:01 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/34747.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 26 Nov 2013 14:53:30 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [Resolved] How can I set the focus on my application at startup on Wed, 04 Dec 2013 19:45:12 GMT]]></title><description><![CDATA[<p dir="auto">I hope it solved your problem. Anyway, did you check the "Paint Touch" (or something like that) demo that comes with Qt 4.81? The're basically implementig a classic Paint for touch devices, I'm pretty sure there was no mouse in there, so you may want to look at it.</p>
]]></description><link>https://forum.qt.io/post/206281</link><guid isPermaLink="true">https://forum.qt.io/post/206281</guid><dc:creator><![CDATA[BlastDV]]></dc:creator><pubDate>Wed, 04 Dec 2013 19:45:12 GMT</pubDate></item><item><title><![CDATA[Reply to [Resolved] How can I set the focus on my application at startup on Wed, 04 Dec 2013 07:24:20 GMT]]></title><description><![CDATA[<p dir="auto">Hi There,</p>
<p dir="auto">Yes, I did try something like this, but it did not work for me in all cases. It works if I make a PC app and run it on the PC, perhaps as you have done as well, but it somehow fails to work on my embedded touch screen app.</p>
<p dir="auto">I am starting to figure that it may be a difference of the OS/Touchscreen.</p>
<p dir="auto">I ended up having to use:<br />
@<br />
#include &lt;QWSServer&gt;<br />
:<br />
QApplication app(argc, argv);<br />
QWSServer::setCursorVisible(false);<br />
@<br />
in main.cpp just after my app is created. I wanted to avoid bringing in more libraries, but I was un-able to get to the route of the cause :(</p>
<p dir="auto">Still, this works nicely, seems to be  a "more powerful" way of controlling the mouse (and other QWS things which I have not yet looked at).</p>
]]></description><link>https://forum.qt.io/post/206179</link><guid isPermaLink="true">https://forum.qt.io/post/206179</guid><dc:creator><![CDATA[code_fodder]]></dc:creator><pubDate>Wed, 04 Dec 2013 07:24:20 GMT</pubDate></item><item><title><![CDATA[Reply to [Resolved] How can I set the focus on my application at startup on Tue, 03 Dec 2013 00:11:46 GMT]]></title><description><![CDATA[<p dir="auto">What if you just call  the next code in your MainWindow constructor:<br />
@setCursor(Qt::BlankCursor);@</p>
<p dir="auto">I've just tested it and It worked fine, with no focus lost. Have you tried this already? :)</p>
]]></description><link>https://forum.qt.io/post/206014</link><guid isPermaLink="true">https://forum.qt.io/post/206014</guid><dc:creator><![CDATA[BlastDV]]></dc:creator><pubDate>Tue, 03 Dec 2013 00:11:46 GMT</pubDate></item></channel></rss>