-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathMessageBox.h
33 lines (29 loc) · 1 KB
/
MessageBox.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#pragma once
#include <QFrame>
#include <QLabel>
#include <QMainWindow>
#include <QMessageBox>
#include <QPushButton>
namespace Examples {
class Window1 : public QMainWindow {
Q_OBJECT
public:
Window1() {
buttonShowMessage.setText("Message...");
buttonShowMessage.move(10, 10);
connect(&buttonShowMessage, &QPushButton::clicked, [&] {
QMessageBox::StandardButton result = QMessageBox::information(this, "Message", "Hello, World!", QMessageBox::StandardButton::Ok|QMessageBox::StandardButton::Cancel);
labelStandardButton.setText(QString("StandardButton = %1").arg(result == QMessageBox::StandardButton::Ok ? "Ok" : "Cancel"));
labelStandardButton.resize(labelStandardButton.sizeHint());
});
labelStandardButton.move(10, 50);
setCentralWidget(&frame);
setWindowTitle("Message box example");
resize(300, 300);
}
private:
QFrame frame;
QPushButton buttonShowMessage {&frame};
QLabel labelStandardButton {&frame};
};
}