<?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[GUI app print to console]]></title><description><![CDATA[<p dir="auto">Hello,</p>
<p dir="auto">I am creating app with GUI (widgets) for Linux. If you run my app it shows GUI (widget), but I want to make my app to be available for console only Linux too (without desktop environment).</p>
<p dir="auto">So is possible that if someone runs my app through console it will not shows GUI (because you can't) but instead of that I will outputs some text into console?</p>
]]></description><link>https://forum.qt.io/topic/91512/gui-app-print-to-console</link><generator>RSS for Node</generator><lastBuildDate>Sun, 03 May 2026 21:19:15 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/91512.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 09 Jun 2018 21:50:54 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to GUI app print to console on Sun, 08 Jul 2018 20:02:00 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">Qt already provides macros for the OS it supports. See <a href="http://doc.qt.io/qt-5/qtglobal.html#Q_OS_AIX" target="_blank" rel="noopener noreferrer nofollow ugc">here</a>.</p>
]]></description><link>https://forum.qt.io/post/468198</link><guid isPermaLink="true">https://forum.qt.io/post/468198</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Sun, 08 Jul 2018 20:02:00 GMT</pubDate></item><item><title><![CDATA[Reply to GUI app print to console on Sun, 08 Jul 2018 18:23:18 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/t0msk">@<bdi>t0msk</bdi></a><br />
hi<br />
Yes, that's the normal way to have different code for<br />
each platform since same calls wont work.<br />
So if you wrap it up in a nice class, and add code for each platform<br />
it will be crossplatform :)</p>
]]></description><link>https://forum.qt.io/post/468186</link><guid isPermaLink="true">https://forum.qt.io/post/468186</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Sun, 08 Jul 2018 18:23:18 GMT</pubDate></item><item><title><![CDATA[Reply to GUI app print to console on Sun, 08 Jul 2018 18:28:06 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mrjj">@<bdi>mrjj</bdi></a> I think it could be cross platform, if I added support for Linux, Windows and Mac like:</p>
<pre><code>#ifdef __linux__ 
    //linux code goes here
#elif _WIN32
    //windows code goes here
#else

#endif
</code></pre>
]]></description><link>https://forum.qt.io/post/468183</link><guid isPermaLink="true">https://forum.qt.io/post/468183</guid><dc:creator><![CDATA[t0msk]]></dc:creator><pubDate>Sun, 08 Jul 2018 18:28:06 GMT</pubDate></item><item><title><![CDATA[Reply to GUI app print to console on Sun, 08 Jul 2018 17:17:59 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/t0msk">@<bdi>t0msk</bdi></a><br />
hi<br />
ok, well it would be ok fine to do in a Qt app.<br />
but its not crossplatform.</p>
]]></description><link>https://forum.qt.io/post/468177</link><guid isPermaLink="true">https://forum.qt.io/post/468177</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Sun, 08 Jul 2018 17:17:59 GMT</pubDate></item><item><title><![CDATA[Reply to GUI app print to console on Sun, 08 Jul 2018 17:12:30 GMT]]></title><description><![CDATA[<p dir="auto">Thank you :) I consider Qt as framework for C++ :) By pure C++ I meant code without Qt classes :)</p>
]]></description><link>https://forum.qt.io/post/468175</link><guid isPermaLink="true">https://forum.qt.io/post/468175</guid><dc:creator><![CDATA[t0msk]]></dc:creator><pubDate>Sun, 08 Jul 2018 17:12:30 GMT</pubDate></item><item><title><![CDATA[Reply to GUI app print to console on Sun, 08 Jul 2018 17:04:55 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/t0msk">@<bdi>t0msk</bdi></a><br />
Hi<br />
Qt is pure c++. :)<br />
But there would not be a Qt class for it.<br />
You would use native windows / linux apis<br />
something like shown here<br />
<a href="https://stackoverflow.com/questions/9009333/how-to-check-if-the-program-is-run-from-a-console" target="_blank" rel="noopener noreferrer nofollow ugc">https://stackoverflow.com/questions/9009333/how-to-check-if-the-program-is-run-from-a-console</a></p>
]]></description><link>https://forum.qt.io/post/468172</link><guid isPermaLink="true">https://forum.qt.io/post/468172</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Sun, 08 Jul 2018 17:04:55 GMT</pubDate></item><item><title><![CDATA[Reply to GUI app print to console on Sun, 08 Jul 2018 16:52:34 GMT]]></title><description><![CDATA[<p dir="auto">Thank you and does have Qt access to some of these API calls? Or it must be done in pure C++?</p>
]]></description><link>https://forum.qt.io/post/468170</link><guid isPermaLink="true">https://forum.qt.io/post/468170</guid><dc:creator><![CDATA[t0msk]]></dc:creator><pubDate>Sun, 08 Jul 2018 16:52:34 GMT</pubDate></item><item><title><![CDATA[Reply to GUI app print to console on Sun, 08 Jul 2018 16:49:10 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/t0msk">@<bdi>t0msk</bdi></a><br />
Well it uses the parameter to know, so it needs some flag in some form or another.<br />
I have not seen other methods, but some could exists involving navtive api calls<br />
to find out if run from a shell or via other means of activation.</p>
]]></description><link>https://forum.qt.io/post/468167</link><guid isPermaLink="true">https://forum.qt.io/post/468167</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Sun, 08 Jul 2018 16:49:10 GMT</pubDate></item><item><title><![CDATA[Reply to GUI app print to console on Sun, 08 Jul 2018 16:42:56 GMT]]></title><description><![CDATA[<p dir="auto">Thank you very much, sorry for late reply, just one more question this is only one way?</p>
<p dir="auto">Or is possible that program will detect if it is run from command line or just by arguments like:</p>
<pre><code>"-no-gui"
</code></pre>
<p dir="auto">?</p>
]]></description><link>https://forum.qt.io/post/468166</link><guid isPermaLink="true">https://forum.qt.io/post/468166</guid><dc:creator><![CDATA[t0msk]]></dc:creator><pubDate>Sun, 08 Jul 2018 16:42:56 GMT</pubDate></item><item><title><![CDATA[Reply to GUI app print to console on Sat, 09 Jun 2018 22:27:37 GMT]]></title><description><![CDATA[<p dir="auto">Hi<br />
yes, its possible.<br />
Doc has sample.<br />
<a href="http://doc.qt.io/qt-5/qapplication.html#details" target="_blank" rel="noopener noreferrer nofollow ugc">http://doc.qt.io/qt-5/qapplication.html#details</a><br />
The trick is to use QCoreApplication  instead of QApplication and<br />
a parameter telling when to run non gui.</p>
<p dir="auto">But for this to work as intended, you must design your app<br />
so any data it needs or function do not<br />
live in mainwindow or other widgets.<br />
Then your app can work in both modes.</p>
]]></description><link>https://forum.qt.io/post/462857</link><guid isPermaLink="true">https://forum.qt.io/post/462857</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Sat, 09 Jun 2018 22:27:37 GMT</pubDate></item></channel></rss>