Within Settings -> Build, Execution, Deployment -> CMake I have set CMake options: to -DCMAKE_PREFIX_PATH=C:\\Qt\\5.12.6\\mingw73_64\\lib\\cmakecmake_minimum_required(VERSION 3.8)project(HelloWorld)set(CMAKE_CXX_STANDARD 14)# Include a library search using find_package()# via REQUIRED, specify that libraries are requiredfind_package(Qt5Core REQUIRED)find_package(Qt5Gui REQUIRED)find_package(Qt5Widgets REQUIRED)set(SOURCE_FILES main.cpp)add_executable(${PROJECT_NAME} ${SOURCE_FILES})# specify which libraries to connecttarget_link_libraries(${PROJECT_NAME} Qt5::Core)target_link_libraries(${PROJECT_NAME} Qt5::Gui)target_link_libraries(${PROJECT_NAME} Qt5::Widgets) main.cpp#include <QtWidgets/QApplication>#include <QtWidgets/QWidget>#include <QtWidgets/QGridLayout>#include <QtWidgets/QLabel>int main (int argc, char * argv []) { QApplication app (argc, argv); QWidget widget; widget.resize (640, 480); widget.setWindowTitle ("Hello, world !!!"); QGridLayout * gridLayout = new QGridLayout (& widget); QLabel * label = new QLabel ("Hello, world !!!"); label-> setAlignment (Qt :: AlignVCenter | Qt :: AlignHCenter); gridLayout-> addWidget (label); widget.show (); return app.exec ();}推荐答案同时,这已为我解决.解决方案如下:转到编辑配置 将Qt bin文件夹添加到工作目录 点击 OK 和/或 APPLYGo to edit configurationsAdd the Qt bin folder to Working directoryHit OK and/or APPLY现在,我可以直接在CLion内部运行和构建Qt应用程序了.Now I am able to run and build my Qt applications from within CLion directly. 这篇关于为什么CLion可以正确构建和链接Qt,但不能运行我的可执行文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-04 00:10