c++ - Console output in a Qt GUI app? -


I have a QT GUI application that is running on Windows which allows to pass the command line option and some In situations I have to output a message for the console and then exit, for example:

  int main (int argc, char * argv []) {QApplication a (argc, argv ); If (some command lineups) {std :: cout & lt; & Lt; "Hello world!"; Return 0; } main window; W.show (); Back a.exec (); }  

However, console messages do not appear when I run the app from a command prompt, does anybody know how I can get it to work?

Windows does not really support dual-mode applications

View console output You need to create a console application

  CONFIG + = console  

However, if you double click to start the GUI mode version The program will show you a console window, which you probably will not want. You must create a GUI mode application in order to stop the console console displayed, in which case you do not get any output in the console.

One idea could be to create a second small application which is a console application and the output. It can call the other to work

Or you can put all the functionality into DLL, then create two versions of the .exe file, which is very simple main function calling the DLL Are there. Is for a GUI and is for a console.


Comments

Popular posts from this blog

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -