TN888
TN888

Reputation: 7739

Segmentation fault error on setupUi()

I have created a projet in Qt. I made design an programmed in Qt Creator. Everything worked propely, but now, all the time, I see Segmentation fault error on ui->setupUi(this) method in my mainForm. I do know what is the reason of this problem. I tried looking in internet, but didn't find anything helpful. I also commented my recent changes - without positive result... Below I post code of my mainForm's .cpp file:

#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
    {

    }

}

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

Any hints will be very appricated. Simple debugging doesn't give me anything.

Upvotes: 3

Views: 1605

Answers (1)

tema
tema

Reputation: 1125

You should try to clean and then re-build your project.
Sometimes QtCreator goes crazy and this problem appears, so you need to do this things manually.
Also you can try to run qmake. To do this just choose this just go to Build tab in menu-bar and select "run qmake" (or smith very similar, it will be placed on bottom).
Hope, this will help.

Upvotes: 5

Related Questions