Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qdialogbuttonbox.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QDIALOGBUTTONBOX_H
6#define QDIALOGBUTTONBOX_H
7
8#include <QtWidgets/qtwidgetsglobal.h>
9#include <QtWidgets/qwidget.h>
10
12
13QT_BEGIN_NAMESPACE
14
15
16class QAbstractButton;
17class QPushButton;
18class QDialogButtonBoxPrivate;
19
20class Q_WIDGETS_EXPORT QDialogButtonBox : public QWidget
21{
22 Q_OBJECT
23 Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation)
24 Q_PROPERTY(StandardButtons standardButtons READ standardButtons WRITE setStandardButtons)
25 Q_PROPERTY(bool centerButtons READ centerButtons WRITE setCenterButtons)
26
27public:
28 enum ButtonRole {
29 // keep this in sync with QMessageBox::ButtonRole and QPlatformDialogHelper::ButtonRole
30 InvalidRole = -1,
31 AcceptRole,
32 RejectRole,
33 DestructiveRole,
34 ActionRole,
35 HelpRole,
36 YesRole,
37 NoRole,
38 ResetRole,
39 ApplyRole,
40
41 NRoles
42 };
43
44 enum StandardButton {
45 // keep this in sync with QMessageBox::StandardButton and QPlatformDialogHelper::StandardButton
46 NoButton = 0x00000000,
47 Ok = 0x00000400,
48 Save = 0x00000800,
49 SaveAll = 0x00001000,
50 Open = 0x00002000,
51 Yes = 0x00004000,
52 YesToAll = 0x00008000,
53 No = 0x00010000,
54 NoToAll = 0x00020000,
55 Abort = 0x00040000,
56 Retry = 0x00080000,
57 Ignore = 0x00100000,
58 Close = 0x00200000,
59 Cancel = 0x00400000,
60 Discard = 0x00800000,
61 Help = 0x01000000,
62 Apply = 0x02000000,
63 Reset = 0x04000000,
64 RestoreDefaults = 0x08000000,
65
66#ifndef Q_MOC_RUN
67 FirstButton = Ok,
68 LastButton = RestoreDefaults
69#endif
70 };
71
72 Q_DECLARE_FLAGS(StandardButtons, StandardButton)
73 Q_FLAG(StandardButtons)
74
75 enum ButtonLayout {
76 // keep this in sync with QPlatformDialogHelper::ButtonLayout
77 WinLayout,
78 MacLayout,
79 KdeLayout,
80 GnomeLayout,
81 AndroidLayout
82 };
83
84 QDialogButtonBox(QWidget *parent = nullptr);
85 QDialogButtonBox(Qt::Orientation orientation, QWidget *parent = nullptr);
86 explicit QDialogButtonBox(StandardButtons buttons, QWidget *parent = nullptr);
87 QDialogButtonBox(StandardButtons buttons, Qt::Orientation orientation,
88 QWidget *parent = nullptr);
89 ~QDialogButtonBox();
90
91 void setOrientation(Qt::Orientation orientation);
92 Qt::Orientation orientation() const;
93
94 void addButton(QAbstractButton *button, ButtonRole role);
95 QPushButton *addButton(const QString &text, ButtonRole role);
96 QPushButton *addButton(StandardButton button);
97 void removeButton(QAbstractButton *button);
98 void clear();
99
100 QList<QAbstractButton *> buttons() const;
101 ButtonRole buttonRole(QAbstractButton *button) const;
102
103 void setStandardButtons(StandardButtons buttons);
104 StandardButtons standardButtons() const;
105 StandardButton standardButton(QAbstractButton *button) const;
106 QPushButton *button(StandardButton which) const;
107
108 void setCenterButtons(bool center);
109 bool centerButtons() const;
110
111 static QString standardButtonText(StandardButton button);
112 static QKeySequence standardButtonShortcut(StandardButton button);
113
114Q_SIGNALS:
115 void clicked(QAbstractButton *button);
116 void accepted();
117 void helpRequested();
118 void rejected();
119
120protected:
121 void changeEvent(QEvent *event) override;
122 bool event(QEvent *event) override;
123
124private:
125 Q_DISABLE_COPY(QDialogButtonBox)
126 Q_DECLARE_PRIVATE(QDialogButtonBox)
127};
128
129Q_DECLARE_OPERATORS_FOR_FLAGS(QDialogButtonBox::StandardButtons)
130
131QT_END_NAMESPACE
132
133#endif // QDIALOGBUTTONBOX_H
The QDialogButtonBox class is a widget that presents buttons in a layout that is appropriate to the c...
void setPageLayout(const QPageLayout &layout)
void setPagePreviewLayout(int columns, int rows)
QPagePreview(QWidget *parent)
void paintEvent(QPaintEvent *) override
This event handler can be reimplemented in a subclass to receive paint events passed in event.
void setPrinter(QPrinter *printer, QPrintDevice *printDevice, QPrinter::OutputFormat outputFormat, const QString &printerName)
QPainter(QPaintDevice *)
Constructs a painter that begins painting the paint device immediately.
friend class QWidget
Definition qpainter.h:432
QT_REQUIRE_CONFIG(printdialog)
QT_REQUIRE_CONFIG(animation)
QT_REQUIRE_CONFIG(liburing)
QMarginsF qt_convertMargins(const QMarginsF &margins, QPageLayout::Unit fromUnits, QPageLayout::Unit toUnits)