TN8*_*888 3 c++ debugging qt segmentation-fault qt-creator
我在 Qt 中创建了一个项目。我在 Qt Creator 中进行了设计编程。一切工作正常,但现在,我一直在 mainForm 中看到方法Segmentation fault错误。ui->setupUi(this)我确实知道这个问题的原因是什么。我尝试在互联网上查找,但没有找到任何有用的东西。我还评论了我最近的更改 - 没有积极的结果...下面我发布了我的 mainForm.cpp文件的代码:
#include "apgmain.h"
#include "ui_apgmain.h"
#include "stdlib.h"
#include "QRegExp"
#include "errorvaldialog.h"
APGMain::APGMain(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::APGMain)
{
ui->setupUi(this); //This line causes error!!!
}
APGMain::~APGMain()
{
delete ui;
}
void APGMain::on_pushButton_clicked()
{
//Exit-button
std::exit(0);
}
void APGMain::on_pushButton_2_clicked()
{
//Generate-button
bool temp = true;
QString tempStr = ui->lineEdit->text();
int minlength = tempStr.toInt(&temp);
if(temp&&minlength>0&&minlength<129)
{
}
else
{
ErrorValDialog* errorval = new ErrorValDialog(this);
errorval->show();
return;
}
}
void APGMain::on_comboBox_currentIndexChanged(const QString &arg1)
{
if(arg1 == "random password generation")
{
}
else
{
}
}
Run Code Online (Sandbox Code Playgroud)
apgmain.h:
#ifndef APGMAIN_H
#define APGMAIN_H
#include <QMainWindow>
namespace Ui {
class APGMain;
}
class APGMain : public QMainWindow
{
Q_OBJECT
public:
explicit APGMain(QWidget *parent = 0);
~APGMain();
private slots:
void on_pushButton_clicked();
void on_pushButton_2_clicked();
void on_comboBox_currentIndexChanged(const QString &arg1);
private:
Ui::APGMain *ui;
};
#endif // APGMAIN_H
Run Code Online (Sandbox Code Playgroud)
任何提示都会非常适用。简单的调试不会给我任何东西。
您应该尝试清理然后重新构建您的项目。
有时 QtCreator 会变得疯狂并出现此问题,因此您需要手动执行此操作。
您也可以尝试运行qmake。要执行此操作,只需选择此选项,只需转到菜单栏中的“构建”选项卡并选择“运行 qmake”(或 smith 非常类似,它将放置在底部)。
希望这会有所帮助。