<?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[Running a Qt Console Application]]></title><description><![CDATA[<p dir="auto">Hello,</p>
<p dir="auto">I have a simple console application that has some header files, source files (.c) and some .lib files that I was able to successfully compile and run in Visual Studio 2010 Express Edition. It simply writes some messages to the terminal, waits for some voice input, process the input and quits after pressing the Q key , etc..</p>
<p dir="auto">I would like to integrate those functions into my Project and I need to use QtCreator. For this I first tried to get the same application running in QtCreator (choosing Qt Console Application) by adding the header and source files and linking the library.</p>
<p dir="auto">It built just fine, but when I execute the program, I just got the terminal window with the message "Please RETURN to close this window", and nothing else.<br />
Then I tried starting from scratch and just having a Qt Console Application and one main.cpp file with :</p>
<p dir="auto">@<br />
#include &lt;iostream&gt;</p>
<p dir="auto">int main()<br />
{<br />
std::cout &lt;&lt; "TESTING console in Qt ... "  &lt;&lt; std::endl;<br />
std::cout &lt;&lt; "TESTING console in Qt ... "  &lt;&lt; std::endl;<br />
std::cout &lt;&lt; "TESTING console in Qt ... "  &lt;&lt; std::endl;<br />
std::cout &lt;&lt; "TESTING console in Qt ... "  &lt;&lt; std::endl;</p>
<pre><code>return 0;
</code></pre>
<p dir="auto">}<br />
@</p>
<p dir="auto">It worked as expected printing the 4 lines to the terminal that pops up when executing. Then I just added the source files and linked to the library files without changing my main.cpp and same thing happened as before. The application compiles with no problem but when executing the debug lines are not being printed to the terminal (or anything else I try to do in the main function gets "ignored").</p>
<p dir="auto">Any ideas of what needs to be done to get this working properly ? Is this because the source files I add are c code and not c++ perhaps?<br />
I would really appreciate any help on this.</p>
<p dir="auto">Thank you very much!</p>
]]></description><link>https://forum.qt.io/topic/27869/running-a-qt-console-application</link><generator>RSS for Node</generator><lastBuildDate>Wed, 20 May 2026 00:36:58 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/27869.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 03 Jun 2013 13:58:49 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Running a Qt Console Application on Tue, 04 Jun 2013 09:00:52 GMT]]></title><description><![CDATA[<p dir="auto">Thanks for the tips, I'll file a bug report then.<br />
Yes, I did have CONFIG += console in my .pro file when I was having the problem.</p>
]]></description><link>https://forum.qt.io/post/181461</link><guid isPermaLink="true">https://forum.qt.io/post/181461</guid><dc:creator><![CDATA[sergex]]></dc:creator><pubDate>Tue, 04 Jun 2013 09:00:52 GMT</pubDate></item><item><title><![CDATA[Reply to Running a Qt Console Application on Mon, 03 Jun 2013 19:18:43 GMT]]></title><description><![CDATA[<p dir="auto">[quote author="Tobias Hunger" date="1370271585"]Do you have "CONFIG   += console" somewhere in your .pro-file? That seems to be important on windows.[/quote]</p>
<p dir="auto">Indeed. If you compile a Windows binary with <em>subsystem</em> "Windows" rather than "Console", then the program won't have a console attached <em>and</em> its STDOUT/STDERR will go to nowhere. Launching the application <em>from</em> a console doesn't change anything about that. The STDOUT/STDERR still goes nowhere.</p>
<p dir="auto">However, applications compiled with <em>subsystem</em> "Windows" may still request a console <em>at runtime</em> via AllocConsole(). But even then STDOUT or STDERR will not work right away! That's because the C-Runtime already was initialized <em>before</em> you request the console. So if you want printf() and <em>cout</em> work as usual, you must first call AllocConsole() and <em>then</em> fix STDOUT/STDERR to actually point to the newly allocated console...</p>
<p dir="auto"><em>You can use something like this:</em><br />
<a href="http://pastie.org/private/pl0hfrnrapd7f88rosmqa" target="_blank" rel="noopener noreferrer nofollow ugc">http://pastie.org/private/pl0hfrnrapd7f88rosmqa</a></p>
]]></description><link>https://forum.qt.io/post/181382</link><guid isPermaLink="true">https://forum.qt.io/post/181382</guid><dc:creator><![CDATA[MuldeR]]></dc:creator><pubDate>Mon, 03 Jun 2013 19:18:43 GMT</pubDate></item><item><title><![CDATA[Reply to Running a Qt Console Application on Mon, 03 Jun 2013 14:59:45 GMT]]></title><description><![CDATA[<p dir="auto">sergex: That does not sound right. It should either work or not work, but working after doing some magic is just wrong:).</p>
<p dir="auto">Could you please "file a bug":<a href="https://bugreports.qt-project.org/" target="_blank" rel="noopener noreferrer nofollow ugc">https://bugreports.qt-project.org/</a> report about this?</p>
<p dir="auto">Do you have "CONFIG   += console" somewhere in your .pro-file? That seems to be important on windows.</p>
]]></description><link>https://forum.qt.io/post/181364</link><guid isPermaLink="true">https://forum.qt.io/post/181364</guid><dc:creator><![CDATA[tobias.hunger]]></dc:creator><pubDate>Mon, 03 Jun 2013 14:59:45 GMT</pubDate></item><item><title><![CDATA[Reply to Running a Qt Console Application on Mon, 03 Jun 2013 14:50:41 GMT]]></title><description><![CDATA[<p dir="auto">Ok, solved this by just going to the "projects" tab on the far left of QtCreator and removing the tick "run in terminal". and running the application. Then if you re set the tick it will work fine in the terminal as well.</p>
]]></description><link>https://forum.qt.io/post/181361</link><guid isPermaLink="true">https://forum.qt.io/post/181361</guid><dc:creator><![CDATA[sergex]]></dc:creator><pubDate>Mon, 03 Jun 2013 14:50:41 GMT</pubDate></item></channel></rss>