Console output in a Qt GUI app?

前端 未结 17 1785
星月不相逢
星月不相逢 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:52

    After a rather long struggle with exactly the same problem I found that simply

    CONFIG   += console
    

    really does the trick. It won't work until you explicitly tell QtCreator to execute qmake on the project (right click on project) AND change something inside the source file, then rebuild. Otherwise compilation is skipped and you still won't see the output on the command line. Now my program works in both GUI and cmd line mode.

提交回复
热议问题