新手求助,使用QT5编译时程序异常结束

leasonw 2017-01-08 01:33:38
本人新手,在使用QT5实现 《C++ GUI QT4》一书中的例子2.3,在编译时发生“程序异常结束”的错误,请问是什么原因?

//pro文件

#-------------------------------------------------
#
# Project created by QtCreator 2017-01-07T23:34:45
#
#-------------------------------------------------

QT += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = gotocellx
TEMPLATE = app

# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked as deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS

# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0


SOURCES += main.cpp\
gotocelldialog.cpp

HEADERS += gotocelldialog.h

FORMS += gotocelldialog.ui

DISTFILES += \
gotocellx.pro.user



//-------------------------------------------------------------------//

//gotocelldialog.h文件

#ifndef GOTOCELLDIALOG_H
#define GOTOCELLDIALOG_H

#include <QDialog>
#include "ui_gotocelldialog.h"

namespace Ui {
class gotocelldialog;
}

class gotocelldialog : public QDialog, public Ui::gotocelldialog
{
Q_OBJECT

public:
explicit gotocelldialog(QWidget *parent = 0);
~gotocelldialog();

private:
Ui::gotocelldialog *ui;
void on_lineEdit_textChanged();
};

#endif // GOTOCELLDIALOG_H

//-------------------------------------------------------------//

//gotocelldialog.cpp文件//

#include "gotocelldialog.h"
#include "ui_gotocelldialog.h"

gotocelldialog::gotocelldialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::gotocelldialog)
{
ui->setupUi(this);
QRegExp regExp("[A-Za-z][1-9][0-9]{0,2}");
lineEdit->setValidator(new QRegExpValidator(regExp,this));

connect(okButton,SIGNAL(clicked()),this,SLOT(accept()));
connect(cancelButton,SIGNAL(clicked()),this,SLOT(reject()));


}

gotocelldialog::~gotocelldialog()
{
delete ui;
}


void gotocelldialog::on_lineEdit_textChanged(){
okButton->setEnabled(lineEdit->hasAcceptableInput());
}


//------------------------------------------------------------------//


//main.cpp//
#include "gotocelldialog.h"
#include <QApplication>

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
gotocelldialog *dialog=new gotocelldialog;
dialog->show();

return a.exec();
}


//-----------------------------------------------------------------------------------------//


提示错误:
Starting F:\QTfiles\build-gotocelly-Desktop_Qt_5_7_1_MSVC2013_64bit-Debug\debug\gotocelly.exe...
程序异常结束。
F:\QTfiles\build-gotocelly-Desktop_Qt_5_7_1_MSVC2013_64bit-Debug\debug\gotocelly.exe crashed.
...全文
721 1 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
赵4老师 2017-01-09
  • 打赏
  • 举报
回复
崩溃的时候在弹出的对话框按相应按钮进入调试,按Alt+7键查看Call Stack即“调用堆栈”里面从上到下列出的对应从里层到外层的函数调用历史。双击某一行可将光标定位到此次调用的源代码或汇编指令处,看不懂时双击下一行,直到能看懂为止
小灸舞 2017-01-09
  • 打赏
  • 举报
回复
这个只能楼主自己查查原因。 1.可以先跑一下QT的示例程序,如果没问题,说明你环境没问题。 2.看看自己的程序是不是用了外部依赖库,没有把对于的DLL放进去 3.是不是程序写的有问题,导致异常结束了

24,860

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 工具平台和程序库
社区管理员
  • 工具平台和程序库社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧