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
qwizard.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 QWIZARD_H
6#define QWIZARD_H
7
8#include <QtWidgets/qtwidgetsglobal.h>
9#include <QtWidgets/qdialog.h>
10
12
13QT_BEGIN_NAMESPACE
14
15class QAbstractButton;
16class QWizardPage;
17class QWizardPrivate;
18
19class Q_WIDGETS_EXPORT QWizard : public QDialog
20{
21 Q_OBJECT
22 Q_PROPERTY(WizardStyle wizardStyle READ wizardStyle WRITE setWizardStyle)
23 Q_PROPERTY(WizardOptions options READ options WRITE setOptions)
24 Q_PROPERTY(Qt::TextFormat titleFormat READ titleFormat WRITE setTitleFormat)
25 Q_PROPERTY(Qt::TextFormat subTitleFormat READ subTitleFormat WRITE setSubTitleFormat)
26 Q_PROPERTY(int startId READ startId WRITE setStartId)
27 Q_PROPERTY(int currentId READ currentId WRITE setCurrentId NOTIFY currentIdChanged)
28 Q_PROPERTY(BannerSizePolicy bannerSizePolicy READ bannerSizePolicy WRITE setBannerSizePolicy REVISION(6, 11))
29
30public:
31 enum WizardButton {
32 BackButton,
33 NextButton,
34 CommitButton,
35 FinishButton,
36 CancelButton,
37 HelpButton,
38 CustomButton1,
39 CustomButton2,
40 CustomButton3,
41 Stretch,
42
43 NoButton = -1,
44 NStandardButtons = 6,
45 NButtons = 9
46 };
47
48 enum WizardPixmap {
49 WatermarkPixmap,
50 LogoPixmap,
51 BannerPixmap,
52 BackgroundPixmap,
53 NPixmaps
54 };
55
56 enum WizardStyle {
57 ClassicStyle,
58 ModernStyle,
59 MacStyle,
60 AeroStyle,
61 NStyles
62 };
63 Q_ENUM(WizardStyle)
64
65 enum class BannerSizePolicy {
66 NoStretch,
67 Stretch,
68 };
69 Q_ENUM(BannerSizePolicy)
70
71 enum WizardOption {
72 IndependentPages = 0x00000001,
73 IgnoreSubTitles = 0x00000002,
74 ExtendedWatermarkPixmap = 0x00000004,
75 NoDefaultButton = 0x00000008,
76 NoBackButtonOnStartPage = 0x00000010,
77 NoBackButtonOnLastPage = 0x00000020,
78 DisabledBackButtonOnLastPage = 0x00000040,
79 HaveNextButtonOnLastPage = 0x00000080,
80 HaveFinishButtonOnEarlyPages = 0x00000100,
81 NoCancelButton = 0x00000200,
82 CancelButtonOnLeft = 0x00000400,
83 HaveHelpButton = 0x00000800,
84 HelpButtonOnRight = 0x00001000,
85 HaveCustomButton1 = 0x00002000,
86 HaveCustomButton2 = 0x00004000,
87 HaveCustomButton3 = 0x00008000,
88 NoCancelButtonOnLastPage = 0x00010000
89 };
90 Q_ENUM(WizardOption)
91
92 Q_DECLARE_FLAGS(WizardOptions, WizardOption)
93 Q_FLAG(WizardOptions)
94
95 explicit QWizard(QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags());
96 ~QWizard();
97
98 int addPage(QWizardPage *page);
99 void setPage(int id, QWizardPage *page);
100 void removePage(int id);
101 QWizardPage *page(int id) const;
102 bool hasVisitedPage(int id) const;
103 QList<int> visitedIds() const;
104 QList<int> pageIds() const;
105 void setStartId(int id);
106 int startId() const;
107 QWizardPage *currentPage() const;
108 int currentId() const;
109
110 virtual bool validateCurrentPage();
111 virtual int nextId() const;
112
113 void setField(const QString &name, const QVariant &value);
114 QVariant field(const QString &name) const;
115
116 void setWizardStyle(WizardStyle style);
117 WizardStyle wizardStyle() const;
118
119 void setOption(WizardOption option, bool on = true);
120 bool testOption(WizardOption option) const;
121 void setOptions(WizardOptions options);
122 WizardOptions options() const;
123
124 void setButtonText(WizardButton which, const QString &text);
125 QString buttonText(WizardButton which) const;
126 void setButtonLayout(const QList<WizardButton> &layout);
127 void setButton(WizardButton which, QAbstractButton *button);
128 QAbstractButton *button(WizardButton which) const;
129
130 void setTitleFormat(Qt::TextFormat format);
131 Qt::TextFormat titleFormat() const;
132 void setSubTitleFormat(Qt::TextFormat format);
133 Qt::TextFormat subTitleFormat() const;
134 void setBannerSizePolicy(BannerSizePolicy bannerSizePolicy);
135 QWizard::BannerSizePolicy bannerSizePolicy() const;
136 void setPixmap(WizardPixmap which, const QPixmap &pixmap);
137 QPixmap pixmap(WizardPixmap which) const;
138
139 void setSideWidget(QWidget *widget);
140 QWidget *sideWidget() const;
141
142 void setDefaultProperty(const char *className, const char *property,
143 const char *changedSignal);
144
145 void setVisible(bool visible) override;
146 QSize sizeHint() const override;
147
148Q_SIGNALS:
149 void currentIdChanged(int id);
150 void helpRequested();
151 void customButtonClicked(int which);
152 void pageAdded(int id);
153 void pageRemoved(int id);
154
155public Q_SLOTS:
156 void back();
157 void next();
158 void setCurrentId(int id);
159 void restart();
160
161protected:
162 bool event(QEvent *event) override;
163 void resizeEvent(QResizeEvent *event) override;
164 void paintEvent(QPaintEvent *event) override;
165#if defined(Q_OS_WIN) || defined(Q_QDOC)
166 bool nativeEvent(const QByteArray &eventType, void *message, qintptr *result) override;
167#endif
168 void done(int result) override;
169 virtual void initializePage(int id);
170 virtual void cleanupPage(int id);
171
172private:
173 Q_DISABLE_COPY(QWizard)
174 Q_DECLARE_PRIVATE(QWizard)
175 Q_PRIVATE_SLOT(d_func(), void _q_emitCustomButtonClicked())
176 Q_PRIVATE_SLOT(d_func(), void _q_updateButtonStates())
177 Q_PRIVATE_SLOT(d_func(), void _q_handleFieldObjectDestroyed(QObject *))
178
179 friend class QWizardPage;
180};
181
182Q_DECLARE_OPERATORS_FOR_FLAGS(QWizard::WizardOptions)
183
184class QWizardPagePrivate;
185
186class Q_WIDGETS_EXPORT QWizardPage : public QWidget
187{
188 Q_OBJECT
189 Q_PROPERTY(QString title READ title WRITE setTitle)
190 Q_PROPERTY(QString subTitle READ subTitle WRITE setSubTitle)
191
192public:
193 explicit QWizardPage(QWidget *parent = nullptr);
194 ~QWizardPage();
195
196 void setTitle(const QString &title);
197 QString title() const;
198 void setSubTitle(const QString &subTitle);
199 QString subTitle() const;
200 void setPixmap(QWizard::WizardPixmap which, const QPixmap &pixmap);
201 QPixmap pixmap(QWizard::WizardPixmap which) const;
202 void setFinalPage(bool finalPage);
203 bool isFinalPage() const;
204 void setCommitPage(bool commitPage);
205 bool isCommitPage() const;
206 void setButtonText(QWizard::WizardButton which, const QString &text);
207 QString buttonText(QWizard::WizardButton which) const;
208
209 virtual void initializePage();
210 virtual void cleanupPage();
211 virtual bool validatePage();
212 virtual bool isComplete() const;
213 virtual int nextId() const;
214
215Q_SIGNALS:
216 void completeChanged();
217
218protected:
219 void setField(const QString &name, const QVariant &value);
220 QVariant field(const QString &name) const;
221 void registerField(const QString &name, QWidget *widget, const char *property = nullptr,
222 const char *changedSignal = nullptr);
223 QWizard *wizard() const;
224
225private:
226 Q_DISABLE_COPY(QWizardPage)
227 Q_DECLARE_PRIVATE(QWizardPage)
228 Q_PRIVATE_SLOT(d_func(), void _q_maybeEmitCompleteChanged())
229 Q_PRIVATE_SLOT(d_func(), void _q_updateCachedCompleteState())
230
231 friend class QWizard;
232 friend class QWizardPrivate;
233};
234
235QT_END_NAMESPACE
236
237#endif // QWIZARD_H
friend class QWidget
Definition qpainter.h:431
The QStylePainter class is a convenience class for drawing QStyle elements inside a widget.
QSize minimumSizeHint() const override
\reimp
Definition qwizard.cpp:432
void setSideWidget(QWidget *widget)
Definition qwizard.cpp:438
QWatermarkLabel(QWidget *parent, QWidget *sideWidget)
Definition qwizard.cpp:426
QWidget * sideWidget() const
Definition qwizard.cpp:449
QWizardAntiFlickerWidget(QWizard *wizard, QWizardPrivate *)
Definition qwizard.cpp:513
QWizardDefaultProperty(const char *className, const char *property, const char *changedSignal)
Definition qwizard.cpp:142
QByteArray changedSignal
Definition qwizard.cpp:139
QString name
Definition qwizard.cpp:159
void resolve(const QList< QWizardDefaultProperty > &defaultPropertyTable)
Definition qwizard.cpp:179
QWizardField(QWizardPage *page, const QString &spec, QObject *object, const char *property, const char *changedSignal)
Definition qwizard.cpp:168
void findProperty(const QWizardDefaultProperty *properties, int propertyCount)
Definition qwizard.cpp:186
QByteArray property
Definition qwizard.cpp:162
QByteArray changedSignal
Definition qwizard.cpp:163
QVariant initialValue
Definition qwizard.cpp:164
QWizardPage * page
Definition qwizard.cpp:158
QObject * object
Definition qwizard.cpp:161
void paintEvent(QPaintEvent *event) override
This event handler can be reimplemented in a subclass to receive paint events passed in event.
Definition qwizard.cpp:392
QWizardHeader(RulerType, QWidget *parent=nullptr)
Definition qwizard.cpp:253
QWizardHeader(QWidget *parent=nullptr)
Definition qwizard.cpp:279
void setup(const QWizardLayoutInfo &info, const QString &title, const QString &subTitle, const QPixmap &logo, const QPixmap &banner, Qt::TextFormat titleFormat, Qt::TextFormat subTitleFormat, QWizard::BannerSizePolicy bannerSizePolicy)
Definition qwizard.cpp:329
bool operator!=(const QWizardLayoutInfo &other) const
Definition qwizard.cpp:222
bool operator==(const QWizardLayoutInfo &other) const
Definition qwizard.cpp:225
TriState completeState
Definition qwizard.cpp:473
void _q_maybeEmitCompleteChanged()
Definition qwizard.cpp:488
QMap< int, QString > buttonCustomTexts
Definition qwizard.cpp:477
void _q_updateCachedCompleteState()
Definition qwizard.cpp:496
bool cachedIsComplete() const
Definition qwizard.cpp:480
QPixmap pixmaps[QWizard::NPixmaps]
Definition qwizard.cpp:471
QList< QWizardField > pendingFields
Definition qwizard.cpp:472
The QWizardPage class is the base class for wizard pages.
Definition qwizard.h:187
QMap< int, QString > buttonCustomTexts
Definition qwizard.cpp:580
QList< int > history
Definition qwizard.cpp:569
QMap< QString, int > fieldIndexMap
Definition qwizard.cpp:567
void setStyle(QStyle *style)
Definition qwizard.cpp:1713
PageMap pageMap
Definition qwizard.cpp:565
QGridLayout * mainLayout
Definition qwizard.cpp:613
QList< QWizardDefaultProperty > defaultPropertyTable
Definition qwizard.cpp:568
QAbstractButton * commit
Definition qwizard.cpp:593
bool buttonLayoutContains(QWizard::WizardButton which)
Definition qwizard.cpp:1511
void updateCurrentPage()
Definition qwizard.cpp:1330
void _q_updateButtonStates()
Definition qwizard.cpp:1635
QVBoxLayout * pageVBoxLayout
Definition qwizard.cpp:611
QWatermarkLabel * watermarkLabel
Definition qwizard.cpp:604
QAbstractButton * cancel
Definition qwizard.cpp:595
QWizardLayoutInfo layoutInfoForCurrentPage()
Definition qwizard.cpp:874
bool startSetByUser
Definition qwizard.cpp:571
void connectButton(QWizard::WizardButton which) const
Definition qwizard.cpp:1399
void removeFieldAt(int index)
Definition qwizard.cpp:759
QAbstractButton * next
Definition qwizard.cpp:592
QAbstractButton * help
Definition qwizard.cpp:596
QAbstractButton * back
Definition qwizard.cpp:591
QLabel * subTitleLabel
Definition qwizard.cpp:608
QFrame * pageFrame
Definition qwizard.cpp:606
QLabel * titleLabel
Definition qwizard.cpp:607
void recreateLayout(const QWizardLayoutInfo &info)
Definition qwizard.cpp:935
QWizardAntiFlickerWidget * antiFlickerWidget
Definition qwizard.cpp:600
QAbstractButton * finish
Definition qwizard.cpp:594
QWizardHeader * headerWidget
Definition qwizard.cpp:603
void updateLayout()
Definition qwizard.cpp:1209
QHBoxLayout * buttonLayout
Definition qwizard.cpp:612
void updateMinMaxSizes(const QWizardLayoutInfo &info)
Definition qwizard.cpp:1294
void _q_emitCustomButtonClicked()
Definition qwizard.cpp:1623
void setButtonLayout(const QWizard::WizardButton *array, int size)
Definition qwizard.cpp:1478
bool isVistaThemeEnabled() const
Definition qwizard.cpp:1596
void updatePixmap(QWizard::WizardPixmap which)
Definition qwizard.cpp:1516
QWidget * sideWidget
Definition qwizard.cpp:605
void _q_handleFieldObjectDestroyed(QObject *)
Definition qwizard.cpp:1686
void switchToPage(int newId, Direction direction)
Definition qwizard.cpp:774
QList< QWizard::WizardButton > buttonsCustomLayout
Definition qwizard.cpp:582
void enableUpdates()
Definition qwizard.cpp:1614
int disableUpdatesCount
Definition qwizard.cpp:576
QPixmap defaultPixmaps[QWizard::NPixmaps]
Definition qwizard.cpp:586
QWidget * placeholderWidget2
Definition qwizard.cpp:602
QWizardRuler * bottomRuler
Definition qwizard.cpp:609
Qt::TextFormat subTitleFmt
Definition qwizard.cpp:584
void updateButtonTexts()
Definition qwizard.cpp:1409
void updateButtonLayout()
Definition qwizard.cpp:1438
QList< QWizardField > fields
Definition qwizard.cpp:566
bool ensureButton(QWizard::WizardButton which) const
Definition qwizard.cpp:1370
void updatePalette()
Definition qwizard.cpp:1270
bool buttonsHaveCustomLayout
Definition qwizard.cpp:581
void cleanupPagesNotInHistory()
Definition qwizard.cpp:723
QAbstractButton * btns[QWizard::NButtons]
Definition qwizard.cpp:598
Qt::TextFormat titleFmt
Definition qwizard.cpp:583
void disableUpdates()
Definition qwizard.cpp:1605
QWidget * placeholderWidget1
Definition qwizard.cpp:601
void addField(const QWizardField &field)
Definition qwizard.cpp:737
QWizardLayoutInfo layoutInfo
Definition qwizard.cpp:575
QWizardRuler(QWidget *parent=nullptr)
Definition qwizard.cpp:419
The QWizard class provides a framework for wizards.
Definition qwizard.h:20
static const char * buttonSlots(QWizard::WizardButton which)
Definition qwizard.cpp:850
static QString buttonDefaultText(int wstyle, int which, const QWizardPrivate *wizardPrivate)
Definition qwizard.cpp:631
const char className[16]
Definition qwizard.cpp:100
static QString object_name_for_button(QWizard::WizardButton which)
Definition qwizard.cpp:1344
Q_DECLARE_TYPEINFO(QWizardDefaultProperty, Q_RELOCATABLE_TYPE)
const int ModernHeaderTopMargin
Definition qwizard.cpp:51
static void changeSpacerSize(QLayout *layout, int index, int width, int height)
Definition qwizard.cpp:59
const int MacLayoutLeftMargin
Definition qwizard.cpp:54
const int GapBetweenLogoAndRightEdge
Definition qwizard.cpp:50
const char property[13]
Definition qwizard.cpp:101
static bool objectInheritsXAndXIsCloserThanY(const QObject *object, const QByteArray &classX, const QByteArray &classY)
Definition qwizard.cpp:85
static QWidget * iWantTheFocus(QWidget *ancestor)
Definition qwizard.cpp:67
Q_DECLARE_TYPEINFO(QWizardField, Q_RELOCATABLE_TYPE)
const int MacLayoutBottomMargin
Definition qwizard.cpp:57
const int MacLayoutRightMargin
Definition qwizard.cpp:56
static const char * changed_signal(int which)
Definition qwizard.cpp:114
const size_t NFallbackDefaultProperties
Definition qwizard.cpp:112
const int ClassicHMargin
Definition qwizard.cpp:52
const int MacButtonTopMargin
Definition qwizard.cpp:53
QT_REQUIRE_CONFIG(wizard)