Console application suspense
I believe I am correct in stating that Qt applications are console applications. My question is this: in Windows, if you run a qt executable from command line, the program starts but immediately gives control back to the console. This prevents the user from seeing couts, cerrs, printfs etc... I know you can output all of this to a file using sample.exe>output.txt for instance, but is there any way to keep control of the command window?
Re: Console application suspense
No. Qt applications are real GUI applications. Nobody says GUI apps can't take command line arguments or that they can't be run from the command line.
If you want to write a console application, use QCoreApplication instead.
You can print stuff to stdout before calling QCoreApplication::exec(). exec is the one that starts the event loop and gives control to your application.
Re: Console application suspense
Ok, so if I used QCoreApplication instead of QApplication for the main, then I would retain control? Or I would maintain control until calling exec?
Re: Console application suspense
You will have to output everything before calling exec.
You could also catch key events and exit when the user presses a key, or something similar.
Re: Console application suspense
Add "CONFIG+=console" to your project file, run qmake and recompile your project. Then everything will become clear.
Re: Console application suspense
Too much effort for not enough payoff. I was hoping it might be a bit simpler
Thank You for the quick response, marcel.
Re: Console application suspense
Just checked this post again and noticed I missed wysota's response. Thank You as well. I will try that.