c – Qt / Qt Creator – 程序意外结束.坠毁
发布时间:2020-12-16 07:07:42 所属栏目:百科 来源:网络整理
导读:我对C和Qt 5.2.1有些新意.我其实是在学习如何使用Qt.为了尽可能简单,我正在使用Qt Creator 3.0.1. 我在我的项目的main.cpp文件中编写了这段小代码: #include QApplication#include QPushButtonint main(int argc,char *argv[]){ QApplication app(argc,argv
我对C和Qt 5.2.1有些新意.我其实是在学习如何使用Qt.为了尽可能简单,我正在使用Qt Creator 3.0.1.
我在我的项目的main.cpp文件中编写了这段小代码: #include <QApplication> #include <QPushButton> int main(int argc,char *argv[]) { QApplication app(argc,argv); QPushButton bouton("Hello !"); bouton.show(); return app.exec(); } 和.pro文件(默认情况下): SOURCES += main.cpp 我试着让它运行,然后我得到了问题“QApplication:没有这样的文件或目录”. 然后,我在.pro文件中添加了“QT = widgets”(完整文件): SOURCES += main.cpp QT += widgets 现在我得到: Starting <path to .exe>... The program has unexpectedly finished. <path to .exe> crashed 请告诉我如何使它工作. (操作系统:Windows 7,调试:桌面Qt 5.2.1 MinGW 32位) 编译输出: 16:06:54: Running steps for project test... 16:06:54: Configuration unchanged,skipping qmake step. 16:06:54: Starting: "C:QtToolsmingw48_32binmingw32-make.exe" C:/Qt/Tools/mingw48_32/bin/mingw32-make -f Makefile.Debug mingw32-make[1]: Entering directory 'C:/Users/PLD/Documents/PLD/Projets Codages/Qt/Qt/build-test-Desktop_Qt_5_2_1_MinGW_32bit-Debug' mingw32-make[1]: Nothing to be done for 'first'. mingw32-make[1]: Leaving directory 'C:/Users/PLD/Documents/PLD/Projets Codages/Qt/Qt/build-test-Desktop_Qt_5_2_1_MinGW_32bit-Debug' 16:06:55: The process "C:QtToolsmingw48_32binmingw32-make.exe" exited normally. 16:06:55: Elapsed time: 00:01. 应用输出: Starting C:UsersPLDDocumentsPLDProjets CodagesQtQtbuild-test-Desktop_Qt_5_2_1_MinGW_32bit-Debugdebugtest.exe... The program has unexpectedly finished. C:UsersPLDDocumentsPLDProjets CodagesQtQtbuild-test-Desktop_Qt_5_2_1_MinGW_32bit-Debugdebugtest.exe crashed 解决方法
代码看起来不错.你得到的一个解释是不兼容的DLL(例如Debug vs Release版本,或MSVC vs MinGW).您可以使用.exe启动depends.exe,并检查它是否从意外位置获取库.
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |