Qt 6.x
The Qt SDK
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
4#ifndef QDIALOGBUTTONBOX_H
5#define QDIALOGBUTTONBOX_H
6
7#include <QtWidgets/qtwidgetsglobal.h>
8#include <QtWidgets/qwidget.h>
9
10QT_REQUIRE_CONFIG(dialogbuttonbox);
11
13
14
15class QAbstractButton;
16class QPushButton;
18
19class Q_WIDGETS_EXPORT QDialogButtonBox : public QWidget
20{
22 Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation)
23 Q_PROPERTY(StandardButtons standardButtons READ standardButtons WRITE setStandardButtons)
24 Q_PROPERTY(bool centerButtons READ centerButtons WRITE setCenterButtons)
25
26public:
28 // keep this in sync with QMessageBox::ButtonRole and QPlatformDialogHelper::ButtonRole
29 InvalidRole = -1,
39
40 NRoles
41 };
42
44 // keep this in sync with QMessageBox::StandardButton and QPlatformDialogHelper::StandardButton
45 NoButton = 0x00000000,
46 Ok = 0x00000400,
47 Save = 0x00000800,
48 SaveAll = 0x00001000,
49 Open = 0x00002000,
50 Yes = 0x00004000,
51 YesToAll = 0x00008000,
52 No = 0x00010000,
53 NoToAll = 0x00020000,
54 Abort = 0x00040000,
55 Retry = 0x00080000,
56 Ignore = 0x00100000,
57 Close = 0x00200000,
58 Cancel = 0x00400000,
59 Discard = 0x00800000,
60 Help = 0x01000000,
61 Apply = 0x02000000,
62 Reset = 0x04000000,
63 RestoreDefaults = 0x08000000,
64
65#ifndef Q_MOC_RUN
66 FirstButton = Ok,
67 LastButton = RestoreDefaults
68#endif
69 };
70
71 Q_DECLARE_FLAGS(StandardButtons, StandardButton)
72 Q_FLAG(StandardButtons)
73
75 // keep this in sync with QPlatformDialogHelper::ButtonLayout
80 AndroidLayout
81 };
82
84 QDialogButtonBox(Qt::Orientation orientation, QWidget *parent = nullptr);
85 explicit QDialogButtonBox(StandardButtons buttons, QWidget *parent = nullptr);
86 QDialogButtonBox(StandardButtons buttons, Qt::Orientation orientation,
87 QWidget *parent = nullptr);
89
90 void setOrientation(Qt::Orientation orientation);
91 Qt::Orientation orientation() const;
92
93 void addButton(QAbstractButton *button, ButtonRole role);
94 QPushButton *addButton(const QString &text, ButtonRole role);
95 QPushButton *addButton(StandardButton button);
96 void removeButton(QAbstractButton *button);
97 void clear();
98
99 QList<QAbstractButton *> buttons() const;
100 ButtonRole buttonRole(QAbstractButton *button) const;
101
102 void setStandardButtons(StandardButtons buttons);
103 StandardButtons standardButtons() const;
104 StandardButton standardButton(QAbstractButton *button) const;
105 QPushButton *button(StandardButton which) const;
106
107 void setCenterButtons(bool center);
108 bool centerButtons() const;
109
110 bool eventFilter(QObject *object, QEvent *event) override;
111
114 void accepted();
116 void rejected();
117
118protected:
119 void changeEvent(QEvent *event) override;
120 bool event(QEvent *event) override;
121
122private:
123 Q_DISABLE_COPY(QDialogButtonBox)
124 Q_DECLARE_PRIVATE(QDialogButtonBox)
125};
126
127Q_DECLARE_OPERATORS_FOR_FLAGS(QDialogButtonBox::StandardButtons)
128
130
131#endif // QDIALOGBUTTONBOX_H
The QAbstractButton class is the abstract base class of button widgets, providing functionality commo...
The QDialogButtonBox class is a widget that presents buttons in a layout that is appropriate to the c...
void clicked(QAbstractButton *button)
This signal is emitted when a button inside the button box is clicked.
void accepted()
This signal is emitted when a button inside the button box is clicked, as long as it was defined with...
StandardButton
These enums describe flags for standard buttons.
ButtonLayout
This enum describes the layout policy to be used when arranging the buttons contained in the button b...
void helpRequested()
This signal is emitted when a button inside the button box is clicked, as long as it was defined with...
void rejected()
This signal is emitted when a button inside the button box is clicked, as long as it was defined with...
\inmodule QtCore
Definition qcoreevent.h:45
Definition qlist.h:74
\inmodule QtCore
Definition qobject.h:90
virtual bool eventFilter(QObject *watched, QEvent *event)
Filters events if this object has been installed as an event filter for the watched object.
Definition qobject.cpp:1518
The QPushButton widget provides a command button.
Definition qpushbutton.h:20
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
virtual void changeEvent(QEvent *)
This event handler can be reimplemented to handle state changes.
Definition qwidget.cpp:9428
b clear()
QString text
QPushButton * button
[2]
Combined button and popup list for selecting options.
Orientation
Definition qnamespace.h:97
@ Ok
Definition qbezier.cpp:275
@ Discard
Definition qbezier.cpp:276
#define Q_DECLARE_FLAGS(Flags, Enum)
Definition qflags.h:174
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
Definition qflags.h:194
struct _cl_event * event
#define QT_REQUIRE_CONFIG(feature)
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_FLAG(x)
#define Q_SIGNALS
msgBox setStandardButtons(QMessageBox::Save|QMessageBox::Discard|QMessageBox::Cancel)
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent
virtual HRESULT STDMETHODCALLTYPE Close(void)=0