| 49 | |
| 50 | private Q_SLOTS: |
| 51 | void closeMessageBox() |
| 52 | { |
| 53 | const QWidgetList allToplevelWidgets = QApplication::topLevelWidgets(); |
| 54 | QMessageBox *mb = nullptr; |
| 55 | for (QWidget *w : allToplevelWidgets) { |
| 56 | if (w->inherits("QMessageBox")) { |
| 57 | mb = qobject_cast<QMessageBox *>(w); |
| 58 | QCOMPARE(mb->text(), m_message); |
| 59 | QCOMPARE(mb->windowTitle(), m_title); |
| 60 | QCOMPARE(mb->icon(), m_icon); |
| 61 | QCheckBox *box = mb->checkBox(); |
| 62 | QCOMPARE(box != nullptr, m_checkBox); |
| 63 | mb->button(m_button)->click(); |
| 64 | } |
| 65 | } |
| 66 | if (!mb) { |
| 67 | QTimer::singleShot(0, this, &MessageBoxHelper::closeMessageBox); |
| 68 | return; |
| 69 | } |
| 70 | m_clicked = true; |
| 71 | } |
| 72 | |
| 73 | private: |
| 74 | QMessageBox::StandardButton m_button; |