Qt Error: The program has unexpectedly finished 解决思想

简介:

    一般出现标题所示错误的原因在于没有对控件实例化,例如:

    在MainWindow.h文件中:

...

private:

    QPushButton *pushButton;

...

    而在MainWindow.cpp文件中:

...

MainWindow::MainWindow(QWidget *parant):QMainWindow(parent){

    pushButton->setText( tr("HelloWorld") );

}

...

    在这种情况下去运行程序,就会出现如上错误。

    解决思想就是实例化:

...

MainWindow::MainWindow(QWidget *parant):QMainWindow(parent){

    pushButton = new QPushButton(this);

    pushButton->setText( tr("HelloWorld") );

}

...

    new一个QPushButton对象即可。


目录
相关文章
|
IDE 开发工具 C++
VS2015+Qt5.9.8编译报错:error MSB6006: “cmd.exe”已退出,代码为 2
VS2015+Qt5.9.8编译报错:error MSB6006: “cmd.exe”已退出,代码为 2
2418 0
如何解决Qt工程在其他电脑上无法运行的问题!(error: cannot open C:\Users???\AppData\Local\Temp\main.obj.5136.0.jom)
如何解决Qt工程在其他电脑上无法运行的问题!(error: cannot open C:\Users???\AppData\Local\Temp\main.obj.5136.0.jom)
关于 国产麒麟系统编译Qt项目是报错:error: cannot find -lGL 的解决方法
关于 国产麒麟系统编译Qt项目是报错:error: cannot find -lGL 的解决方法
关于 国产麒麟系统编译Qt项目是报错:error: cannot find -lGL 的解决方法
|
编译器 计算机视觉
关于 Qt编译时使用msvc编译器报错“Error: cannot open ...main.obj.10836.32.jom for write” 的解决方法
关于 Qt编译时使用msvc编译器报错“Error: cannot open ...main.obj.10836.32.jom for write” 的解决方法
关于 Qt编译时使用msvc编译器报错“Error: cannot open ...main.obj.10836.32.jom for write” 的解决方法
|
Linux 计算机视觉
关于 编译qt项目时报错:error: cannot find -lGLESv2 的解决方法
关于 编译qt项目时报错:error: cannot find -lGLESv2 的解决方法
|
计算机视觉
关于 编译QT项目时报错: error: cannot find -lGL 的解决方法
关于 编译QT项目时报错: error: cannot find -lGL 的解决方法
|
编译器 开发工具 Windows
Qt使用过程中,遇到error及解决方法总结
Qt使用过程中,遇到error及解决方法总结
|
编译器 C语言 Windows
windows下在QT里调用ffmpeg库处理音频视频数据时,出现error missing -D__STDC_FORMAT_MACROS 错误的解决方法(MINGW32编译器)。
windows下在QT里调用ffmpeg库处理音频视频数据时,出现error missing -D__STDC_FORMAT_MACROS 错误的解决方法(MINGW32编译器)。
478 0
windows下在QT里调用ffmpeg库处理音频视频数据时,出现error missing -D__STDC_FORMAT_MACROS 错误的解决方法(MINGW32编译器)。
Qt 编译时遇到 error: [debug/qrc_music.cpp] Error 1
第一种方式,清理编译文件 把Qdebug release 文件件都删除, 删除makefile 文件 尝试重新编译 以上是网上寻找的结果 以下是我的解决方法
525 0
|
Windows
Qt Creator编译项目,报错,error: LNK1158: 无法运行“rc.exe”
Qt Creator编译项目,报错,error: LNK1158: 无法运行“rc.exe”
741 0