blob: ae2fb93bf7963e8c5bd03ab5dd6ab32cde6d389b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
#include <QApplication>
#include <QMessageBox>
#include <QPushButton>
#include <QString>
#include <QTimer>
#include <QWidget>
void ConfirmMessage(QString* text, int msec)
{
QTimer::singleShot(msec, [text]() {
for (QWidget* widget : QApplication::topLevelWidgets()) {
if (widget->inherits("QMessageBox")) {
QMessageBox* messageBox = qobject_cast<QMessageBox*>(widget);
if (text) *text = messageBox->text();
messageBox->defaultButton()->click();
}
}
});
}
|