How do I keep my Qt C++ program from opening a console in Windows?

后端 未结 5 1984
有刺的猬
有刺的猬 2021-02-19 10:10

I\'m making an application in Qt Creator, with cmake and MinGW as compiler. I\'ve seen this question being answered for other people, but they used regular Qt projects with .pro

5条回答
  •  暖寄归人
    2021-02-19 11:12

    You will most likely have a line such as the following in your CMakeLists.txt:

    ADD_EXECUTABLE(exename ....)
    

    where of course the dots are further arguments. Change this to:

    ADD_EXECUTABLE(exename [WIN32] ...)
    

    to specify that it's a Win32 application and not a console application.

    Or, as can be found on the CMAKE website "If WIN32 is given the property WIN32_EXECUTABLE will be set on the target created." And when WIN32_EXECUTABLE is set it will "Build an executable with a WinMain entry point on windows."

提交回复
热议问题