最近在用Qt写一个GUI,最后release之后发现,伴随窗口启动的还有一个console窗口
我用的是mingw+cmake的编译方法,查了很多资料终于找到了解决方法,如下:
在CMakeList.txt中添加,然后console窗口就不见啦
#隐藏console if(WIN32) if(MSVC) set_target_properties(${PROJECT_NAME} PROPERTIES WIN32_EXECUTABLE YES LINK_FLAGS "/ENTRY:mainCRTStartup" ) elseif(CMAKE_COMPILER_IS_GNUCXX) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mwindows") # Not tested else() message(SEND_ERROR "You are using an unsupported Windows compiler! (Not MSVC or GCC)") endif(MSVC) elseif(APPLE) set_target_properties(${PROJECT_NAME} PROPERTIES MACOSX_BUNDLE YES ) elseif(UNIX) # Nothing special required else() message(SEND_ERROR "You are on an unsupported platform! (Not Win32, Mac OS X or Unix)") endif(WIN32)
其他参考:
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);标签:cmake,Qt,CMAKE,MSVC,elseif,console,窗口 From: https://www.cnblogs.com/chinasoft/p/18402303
QApplication::setStyle("fusion");