I created a new project with 2 dialogs, the sources are mainwindow.cpp and dialog.cpp.
The code in dialog.cpp looks like this:
#include "dialog.h"
#include "ui_dialog.h"
Dialog::Dialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog)
{
ui->setupUi(this);
}
Dialog::~Dialog()
{
delete ui;
}
void Dialog::message()
{
QMessageBox::StandardButton reply;
reply = QMessageBox::information(this, "Confirmation","<b><font size='16' color='green'>Do you want to close the 2nd window?</font></b>",QMessageBox::Yes | QMessageBox::No);
if(reply == QMessageBox::Yes)
{
qDebug() << "Yes was clicked. Close 2nd.";
this->reject();
}
else
{
qDebug() << "No was clicked. Don't close 2nd.";
}
}
void Dialog::on_pushButton_clicked()
{
message();
}
When I click yes, it does what I want, it closes dialog. When I use the same code in my original application, it does nothing (no error message either). What can cause this completely different behavior? Thank you.