lundi 2 octobre 2017

Why the app crashes on pressing submit button in Qt?

Following is my definition of confirm window( the window that is opened on clicking submit button in main window). confirmwindow.h

#ifndef CONFIRMWINDOW_H
#define CONFIRMWINDOW_H

#include <QDialog>

namespace Ui {
class ConfirmWindow;
}

class ConfirmWindow : public QDialog
{
    Q_OBJECT

public:
    explicit ConfirmWindow(QWidget *parent = 0);
    ConfirmWindow(QString name);
    ~ConfirmWindow();

private:
    Ui::ConfirmWindow *ui;
};

#endif // CONFIRMWINDOW_H

And in confirmwindow.cpp I defined in following manner

#include "confirmwindow.h"
#include "ui_confirmwindow.h"

ConfirmWindow::ConfirmWindow(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::ConfirmWindow)
{
    ui->setupUi(this);
}

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

ConfirmWindow::ConfirmWindow(QString name)
{
    ui->label_show_name->setText(name);
}

when I run the program it all goes well untill I press submit button, which crashes the app with a message in console as The program has unexpectedly finished. I guess, I am defining the constructor in a wrong way in confirmwindow.cpp file.

Aucun commentaire:

Enregistrer un commentaire