C++ QT5 运行时错误read access violation at: 0x0, flags=0x0 (first chance)

gouckchenwy 2014-08-20 01:38:41
//logindlg.h
#ifndef SIGNINDLG_H
#define SIGNINDLG_H

#include <QDialog>
#include<QMessageBox>
#include<QString>
#include<QPushButton>
#include"ui_signindlg.h"

using namespace std;

namespace Ui {
class SignInDlg;
}

class SignInDlg : public QDialog, public Ui::SignInDlg
{

Q_OBJECT

public:

explicit SignInDlg(QWidget *parent = 0);

~SignInDlg();

void check();

private:

Ui::SignInDlg *ui;
};

#endif // SIGNINDLG_H

//logindlg.cpp
#include "signindlg.h"
#include "ui_signindlg.h"

SignInDlg::SignInDlg(QWidget *parent) :

QDialog(parent),

ui(new Ui::SignInDlg)
{

ui->setupUi(this);

//此处发生错误
QObject::connect(pushButton, &QPushButton::clicked, this, &SignInDlg::check);

check();
}

void SignInDlg::check()
{

QString username;

QString password;

username = ui->usernameLineEdit->text();

if (username.length() > 16)

{

QMessageBox msgBox;

msgBox.setText("Username cannot be longer than 16 chars!");

msgBox.setStandardButtons(QMessageBox::Yes);

msgBox.setDefaultButton(QMessageBox::Yes);

}
}

SignInDlg::~SignInDlg()
{

delete ui;
}


异常被触发:
底层停止了因为它触发了一个异常。

在线程0中停止,因为: Exception at 0x6d9a937a, code: 0xc0000005: read access violation at: 0x0, flags=0x0。
...全文
1244 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
火头军 2014-08-20
  • 打赏
  • 举报
回复
指针访问越界,你的pushbutton 哪里来的

24,855

社区成员

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

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