That's about the logic, how to make MessageBox itself, I know. I cram the code into the destructor:

L_9_1K::~L_9_1K() { QMessageBox msgBox; msgBox.show(); msgBox.setText("Cохранить перед выходом?"); msgBox.addButton(QWidget::tr("OК"), QMessageBox::RejectRole); msgBox.addButton(QWidget::tr("отменить"), QMessageBox::RejectRole); msgBox.setIcon(QMessageBox::Information); int res = msgBox.exec(); if (res == QWidget::tr("OК")) saveSettings(); //сохраняет настройки приложения delete ui; if (res == QWidget::tr("Отменить")) delete ui; }` 

Please tell me where is the error?

  • one
    that's right, but not in the destructor, but in closeEvent - Bearded Beaver
  • and still QMessageBox create / get the result wrong ... - Fat-Zer 2:49 pm

1 answer 1

If your class is derived from QDialog, then this code should be inserted into the redefined function reject (), if from QWidget, then in closeEvent ()