Console output in a Qt GUI app?

前端 未结 17 1720
星月不相逢
星月不相逢 2020-11-28 07:06

I have a Qt GUI application running on Windows that allows command-line options to be passed and under some circumstances I want to output a message to the console and then

17条回答
  •  攒了一身酷
    2020-11-28 07:54

    Windows does not really support dual mode applications.

    To see console output you need to create a console application

    CONFIG += console
    

    However, if you double click on the program to start the GUI mode version then you will get a console window appearing, which is probably not what you want. To prevent the console window appearing you have to create a GUI mode application in which case you get no output in the console.

    One idea may be to create a second small application which is a console application and provides the output. This can call the second one to do the work.

    Or you could put all the functionality in a DLL then create two versions of the .exe file which have very simple main functions which call into the DLL. One is for the GUI and one is for the console.

提交回复
热议问题