Bitcoin Core  22.99.0
P2P Digital Currency
util.cpp
Go to the documentation of this file.
1 // Copyright (c) 2018-2020 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #include <chrono>
6 
7 #include <QApplication>
8 #include <QMessageBox>
9 #include <QPushButton>
10 #include <QString>
11 #include <QTimer>
12 #include <QWidget>
13 
14 void ConfirmMessage(QString* text, std::chrono::milliseconds msec)
15 {
16  QTimer::singleShot(msec, [text]() {
17  for (QWidget* widget : QApplication::topLevelWidgets()) {
18  if (widget->inherits("QMessageBox")) {
19  QMessageBox* messageBox = qobject_cast<QMessageBox*>(widget);
20  if (text) *text = messageBox->text();
21  messageBox->defaultButton()->click();
22  }
23  }
24  });
25 }
ConfirmMessage
void ConfirmMessage(QString *text, std::chrono::milliseconds msec)
Press "Ok" button in message box dialog.
Definition: util.cpp:14