QtBase  v6.3.1
qdialogbuttonbox.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of the QtWidgets module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and The Qt Company. For licensing terms
14 ** and conditions see https://www.qt.io/terms-conditions. For further
15 ** information use the contact form at https://www.qt.io/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 3 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL3 included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 3 requirements
23 ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
24 **
25 ** GNU General Public License Usage
26 ** Alternatively, this file may be used under the terms of the GNU
27 ** General Public License version 2.0 or (at your option) the GNU General
28 ** Public license version 3 or any later version approved by the KDE Free
29 ** Qt Foundation. The licenses are as published by the Free Software
30 ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
31 ** included in the packaging of this file. Please review the following
32 ** information to ensure the GNU General Public License requirements will
33 ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
34 ** https://www.gnu.org/licenses/gpl-3.0.html.
35 **
36 ** $QT_END_LICENSE$
37 **
38 ****************************************************************************/
39 
40 #ifndef QDIALOGBUTTONBOX_H
41 #define QDIALOGBUTTONBOX_H
42 
43 #include <QtWidgets/qtwidgetsglobal.h>
44 #include <QtWidgets/qwidget.h>
45 
46 QT_REQUIRE_CONFIG(dialogbuttonbox);
47 
49 
50 
51 class QAbstractButton;
52 class QPushButton;
54 
55 class Q_WIDGETS_EXPORT QDialogButtonBox : public QWidget
56 {
57  Q_OBJECT
58  Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation)
59  Q_PROPERTY(StandardButtons standardButtons READ standardButtons WRITE setStandardButtons)
60  Q_PROPERTY(bool centerButtons READ centerButtons WRITE setCenterButtons)
61 
62 public:
63  enum ButtonRole {
64  // keep this in sync with QMessageBox::ButtonRole and QPlatformDialogHelper::ButtonRole
65  InvalidRole = -1,
75 
76  NRoles
77  };
78 
80  // keep this in sync with QMessageBox::StandardButton and QPlatformDialogHelper::StandardButton
81  NoButton = 0x00000000,
82  Ok = 0x00000400,
83  Save = 0x00000800,
84  SaveAll = 0x00001000,
85  Open = 0x00002000,
86  Yes = 0x00004000,
87  YesToAll = 0x00008000,
88  No = 0x00010000,
89  NoToAll = 0x00020000,
90  Abort = 0x00040000,
91  Retry = 0x00080000,
92  Ignore = 0x00100000,
93  Close = 0x00200000,
94  Cancel = 0x00400000,
95  Discard = 0x00800000,
96  Help = 0x01000000,
97  Apply = 0x02000000,
98  Reset = 0x04000000,
99  RestoreDefaults = 0x08000000,
100 
101 #ifndef Q_MOC_RUN
102  FirstButton = Ok,
103  LastButton = RestoreDefaults
104 #endif
105  };
106 
107  Q_DECLARE_FLAGS(StandardButtons, StandardButton)
108  Q_FLAG(StandardButtons)
109 
111  // keep this in sync with QPlatformDialogHelper::ButtonLayout
116  AndroidLayout
117  };
118 
119  QDialogButtonBox(QWidget *parent = nullptr);
120  QDialogButtonBox(Qt::Orientation orientation, QWidget *parent = nullptr);
121  explicit QDialogButtonBox(StandardButtons buttons, QWidget *parent = nullptr);
122  QDialogButtonBox(StandardButtons buttons, Qt::Orientation orientation,
123  QWidget *parent = nullptr);
124  ~QDialogButtonBox();
125 
126  void setOrientation(Qt::Orientation orientation);
127  Qt::Orientation orientation() const;
128 
129  void addButton(QAbstractButton *button, ButtonRole role);
130  QPushButton *addButton(const QString &text, ButtonRole role);
131  QPushButton *addButton(StandardButton button);
132  void removeButton(QAbstractButton *button);
133  void clear();
134 
135  QList<QAbstractButton *> buttons() const;
136  ButtonRole buttonRole(QAbstractButton *button) const;
137 
138  void setStandardButtons(StandardButtons buttons);
139  StandardButtons standardButtons() const;
140  StandardButton standardButton(QAbstractButton *button) const;
141  QPushButton *button(StandardButton which) const;
142 
143  void setCenterButtons(bool center);
144  bool centerButtons() const;
145 
146 Q_SIGNALS:
148  void accepted();
150  void rejected();
151 
152 protected:
153  void changeEvent(QEvent *event) override;
154  bool event(QEvent *event) override;
155 
156 private:
158  Q_DECLARE_PRIVATE(QDialogButtonBox)
159  Q_PRIVATE_SLOT(d_func(), void _q_handleButtonClicked())
160  Q_PRIVATE_SLOT(d_func(), void _q_handleButtonDestroyed())
161 };
162 
164 
166 
167 #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)
The QEvent class is the base class of all event classes. Event objects contain event parameters.
Definition: qcoreevent.h:58
The QPushButton widget provides a command button.
Definition: qpushbutton.h:56
The QString class provides a Unicode character string.
Definition: qstring.h:388
The QWidget class is the base class of all user interface objects.
Definition: qwidget.h:133
virtual void changeEvent(QEvent *)
Definition: qwidget.cpp:9283
bool event(QEvent *event) override
Definition: qwidget.cpp:8772
msgBox setStandardButtons(QMessageBox::Yes|QMessageBox::No)
b clear()
QPushButton * button
[2]
@ NoButton
Definition: qnamespace.h:82
Orientation
Definition: qnamespace.h:123
QTextStream & center(QTextStream &stream)
@ Ok
Definition: qbezier.cpp:209
@ Discard
Definition: qbezier.cpp:210
QT_REQUIRE_CONFIG(dialogbuttonbox)
#define Q_DECLARE_FLAGS(Flags, Enum)
Definition: qflags.h:210
#define Q_DECLARE_OPERATORS_FOR_FLAGS(Flags)
Definition: qflags.h:227
#define Q_DISABLE_COPY(Class)
Definition: qglobal.h:515
@ text
struct _cl_event * event
Definition: qopenglext.h:2998
#define Q_PROPERTY(...)
Definition: qtmetamacros.h:92
#define Q_OBJECT
Definition: qtmetamacros.h:158
#define Q_FLAG(x)
Definition: qtmetamacros.h:105
#define Q_PRIVATE_SLOT(d, signature)
Definition: qtmetamacros.h:82
#define Q_SIGNALS
Definition: qtmetamacros.h:81
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent
virtual HRESULT STDMETHODCALLTYPE Close(void)=0