Qt / Qt Creator-程序意外完成。<程序的路径>崩溃

PLD*_*PLD 5 c++ qt qt-creator

我是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();

}
Run Code Online (Sandbox Code Playgroud)

和.pro文件(默认情况下):

SOURCES += \
    main.cpp
Run Code Online (Sandbox Code Playgroud)

我试图使其运行,然后出现问题“ QApplication:没有这样的文件或目录”。

然后,我在.pro文件(完整文件)中添加了“ QT + =小部件”:

SOURCES += \
    main.cpp
QT += widgets
Run Code Online (Sandbox Code Playgroud)

现在我得到:

Starting <path to .exe>... 
The program has unexpectedly finished.
<path to .exe> crashed
Run Code Online (Sandbox Code Playgroud)

请告诉我如何使它工作。感谢您的阅读和帮助。

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

编译输出:

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.
Run Code Online (Sandbox Code Playgroud)

应用输出:

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
Run Code Online (Sandbox Code Playgroud)

PLD*_*PLD -1

我查遍了整个网络,寻找如何安装 Qt5。关于它的教程还不够多,而且要让它在 Windows 上正常工作也很令人费解。

我终于安装了Qt4,它更稳定,更容易运行。