Qt/Qt Creator - The program has unexpectedly finished. <program's path> crashed

ε祈祈猫儿з 提交于 2019-12-10 14:16:07

问题


I'm somewhat new to C++ and to Qt 5.2.1. I'm actually learning how to use Qt. To do it as easy as possible, I'm using Qt Creator 3.0.1.

I've written this little piece of code in the main.cpp file of my project :

#include <QApplication>
#include <QPushButton>

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    QPushButton bouton("Hello !");
    bouton.show();

    return app.exec();

}

And the .pro file (by default) :

SOURCES += \
    main.cpp

I tried to make it run, then I got the issue "QApplication : no such file or directory".

Then, I added "QT += widgets" to the .pro file (full file) :

SOURCES += \
    main.cpp
QT += widgets

And now I get :

Starting <path to .exe>... 
The program has unexpectedly finished.
<path to .exe> crashed

Please, tell me how to make it work. Thanks for reading and for your help.

(OS : Windows 7, Debug : Desktop Qt 5.2.1 MinGW 32bit)

Compile Output :

16:06:54: Running steps for project test...
16:06:54: Configuration unchanged, skipping qmake step.
16:06:54: Starting: "C:\Qt\Tools\mingw48_32\bin\mingw32-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:\Qt\Tools\mingw48_32\bin\mingw32-make.exe" exited normally.
16:06:55: Elapsed time: 00:01.

Application Output :

Starting C:\Users\PLD\Documents\PLD\Projets Codages\Qt\Qt\build-test-Desktop_Qt_5_2_1_MinGW_32bit-Debug\debug\test.exe...
The program has unexpectedly finished.
C:\Users\PLD\Documents\PLD\Projets Codages\Qt\Qt\build-test-Desktop_Qt_5_2_1_MinGW_32bit-Debug\debug\test.exe crashed

回答1:


The code looks good. One explanation for what you get would be incompatible DLLs (e.g. Debug vs Release builds, or MSVC vs MinGW). You could start depends.exe with your .exe and check whether it picks up libraries from unexpected locations.




回答2:


I've look all over the web, seeking how to install Qt5. There's not enough tutorials on it and it's very puzzling to make it work properly on Windows.

I have finally installed Qt4, which is more stable and easier to make it work.



来源:https://stackoverflow.com/questions/21647119/qt-qt-creator-the-program-has-unexpectedly-finished-programs-path-crashed

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!