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
29public:
30 enum WizardButton {
31 BackButton,
32 NextButton,
33 CommitButton,
34 FinishButton,
35 CancelButton,
36 HelpButton,
37 CustomButton1,
38 CustomButton2,
39 CustomButton3,
40 Stretch,
41
42 NoButton = -1,
43 NStandardButtons = 6,
44 NButtons = 9
45 };
46
47 enum WizardPixmap {
48 WatermarkPixmap,
49 LogoPixmap,
50 BannerPixmap,
51 BackgroundPixmap,
52 NPixmaps
53 };
54
55 enum WizardStyle {
56 ClassicStyle,
57 ModernStyle,
58 MacStyle,
59 AeroStyle,
60 NStyles
61 };
62 Q_ENUM(WizardStyle)
63
64 enum class BannerStretchPolicy {
65 NoStretch,
66 Stretch,
67 };
68 Q_ENUM(BannerStretchPolicy)
69
70 enum WizardOption {
71 IndependentPages = 0x00000001,
72 IgnoreSubTitles = 0x00000002,
73 ExtendedWatermarkPixmap = 0x00000004,
74 NoDefaultButton = 0x00000008,
75 NoBackButtonOnStartPage = 0x00000010,
76 NoBackButtonOnLastPage = 0x00000020,
77 DisabledBackButtonOnLastPage = 0x00000040,
78 HaveNextButtonOnLastPage = 0x00000080,
79 HaveFinishButtonOnEarlyPages = 0x00000100,
80 NoCancelButton = 0x00000200,
81 CancelButtonOnLeft = 0x00000400,
82 HaveHelpButton = 0x00000800,
83 HelpButtonOnRight = 0x00001000,
84 HaveCustomButton1 = 0x00002000,
85 HaveCustomButton2 = 0x00004000,
86 HaveCustomButton3 = 0x00008000,
87 NoCancelButtonOnLastPage = 0x00010000,
88 StretchBanner = 0x00020000,
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 setPixmap(WizardPixmap which, const QPixmap &pixmap);
135 QPixmap pixmap(WizardPixmap which) const;
136
137 void setSideWidget(QWidget *widget);
138 QWidget *sideWidget() const;
139
140 void setDefaultProperty(const char *className, const char *property,
141 const char *changedSignal);
142
143 void setVisible(bool visible) override;
144 QSize sizeHint() const override;
145
146Q_SIGNALS:
147 void currentIdChanged(int id);
148 void helpRequested();
149 void customButtonClicked(int which);
150 void pageAdded(int id);
151 void pageRemoved(int id);
152
153public Q_SLOTS:
154 void back();
155 void next();
156 void setCurrentId(int id);
157 void restart();
158
159protected:
160 bool event(QEvent *event) override;
161 void resizeEvent(QResizeEvent *event) override;
162 void paintEvent(QPaintEvent *event) override;
163#if defined(Q_OS_WIN) || defined(Q_QDOC)
164 bool nativeEvent(const QByteArray &eventType, void *message, qintptr *result) override;
165#endif
166 void done(int result) override;
167 virtual void initializePage(int id);
168 virtual void cleanupPage(int id);
169
170private:
171 Q_DISABLE_COPY(QWizard)
172 Q_DECLARE_PRIVATE(QWizard)
173 Q_PRIVATE_SLOT(d_func(), void _q_emitCustomButtonClicked())
174 Q_PRIVATE_SLOT(d_func(), void _q_updateButtonStates())
175 Q_PRIVATE_SLOT(d_func(), void _q_handleFieldObjectDestroyed(QObject *))
176
177 friend class QWizardPage;
178};
179
180Q_DECLARE_OPERATORS_FOR_FLAGS(QWizard::WizardOptions)
181
182class QWizardPagePrivate;
183
184class Q_WIDGETS_EXPORT QWizardPage : public QWidget
185{
186 Q_OBJECT
187 Q_PROPERTY(QString title READ title WRITE setTitle)
188 Q_PROPERTY(QString subTitle READ subTitle WRITE setSubTitle)
189
190public:
191 explicit QWizardPage(QWidget *parent = nullptr);
192 ~QWizardPage();
193
194 void setTitle(const QString &title);
195 QString title() const;
196 void setSubTitle(const QString &subTitle);
197 QString subTitle() const;
198 void setPixmap(QWizard::WizardPixmap which, const QPixmap &pixmap);
199 QPixmap pixmap(QWizard::WizardPixmap which) const;
200 void setFinalPage(bool finalPage);
201 bool isFinalPage() const;
202 void setCommitPage(bool commitPage);
203 bool isCommitPage() const;
204 void setButtonText(QWizard::WizardButton which, const QString &text);
205 QString buttonText(QWizard::WizardButton which) const;
206
207 virtual void initializePage();
208 virtual void cleanupPage();
209 virtual bool validatePage();
210 virtual bool isComplete() const;
211 virtual int nextId() const;
212
213Q_SIGNALS:
214 void completeChanged();
215
216protected:
217 void setField(const QString &name, const QVariant &value);
218 QVariant field(const QString &name) const;
219 void registerField(const QString &name, QWidget *widget, const char *property = nullptr,
220 const char *changedSignal = nullptr);
221 QWizard *wizard() const;
222
223private:
224 Q_DISABLE_COPY(QWizardPage)
225 Q_DECLARE_PRIVATE(QWizardPage)
226 Q_PRIVATE_SLOT(d_func(), void _q_maybeEmitCompleteChanged())
227 Q_PRIVATE_SLOT(d_func(), void _q_updateCachedCompleteState())
228
229 friend class QWizard;
230 friend class QWizardPrivate;
231};
232
233QT_END_NAMESPACE
234
235#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:427
void setSideWidget(QWidget *widget)
Definition qwizard.cpp:433
QWatermarkLabel(QWidget *parent, QWidget *sideWidget)
Definition qwizard.cpp:421
QWidget * sideWidget() const
Definition qwizard.cpp:444
QWizardAntiFlickerWidget(QWizard *wizard, QWizardPrivate *)
Definition qwizard.cpp:508
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:390
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::WizardOptions wizardOptions)
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:468
void _q_maybeEmitCompleteChanged()
Definition qwizard.cpp:483
QMap< int, QString > buttonCustomTexts
Definition qwizard.cpp:472
void _q_updateCachedCompleteState()
Definition qwizard.cpp:491
bool cachedIsComplete() const
Definition qwizard.cpp:475
QPixmap pixmaps[QWizard::NPixmaps]
Definition qwizard.cpp:466
QList< QWizardField > pendingFields
Definition qwizard.cpp:467
The QWizardPage class is the base class for wizard pages.
Definition qwizard.h:185
QMap< int, QString > buttonCustomTexts
Definition qwizard.cpp:575
QList< int > history
Definition qwizard.cpp:564
QMap< QString, int > fieldIndexMap
Definition qwizard.cpp:562
void setStyle(QStyle *style)
Definition qwizard.cpp:1707
PageMap pageMap
Definition qwizard.cpp:560
QGridLayout * mainLayout
Definition qwizard.cpp:607
QList< QWizardDefaultProperty > defaultPropertyTable
Definition qwizard.cpp:563
QAbstractButton * commit
Definition qwizard.cpp:587
bool buttonLayoutContains(QWizard::WizardButton which)
Definition qwizard.cpp:1505
void updateCurrentPage()
Definition qwizard.cpp:1324
void _q_updateButtonStates()
Definition qwizard.cpp:1629
QVBoxLayout * pageVBoxLayout
Definition qwizard.cpp:605
QWatermarkLabel * watermarkLabel
Definition qwizard.cpp:598
QAbstractButton * cancel
Definition qwizard.cpp:589
QWizardLayoutInfo layoutInfoForCurrentPage()
Definition qwizard.cpp:868
bool startSetByUser
Definition qwizard.cpp:566
void connectButton(QWizard::WizardButton which) const
Definition qwizard.cpp:1393
void removeFieldAt(int index)
Definition qwizard.cpp:753
QAbstractButton * next
Definition qwizard.cpp:586
QAbstractButton * help
Definition qwizard.cpp:590
QAbstractButton * back
Definition qwizard.cpp:585
QLabel * subTitleLabel
Definition qwizard.cpp:602
QFrame * pageFrame
Definition qwizard.cpp:600
QLabel * titleLabel
Definition qwizard.cpp:601
void recreateLayout(const QWizardLayoutInfo &info)
Definition qwizard.cpp:929
QWizardAntiFlickerWidget * antiFlickerWidget
Definition qwizard.cpp:594
QAbstractButton * finish
Definition qwizard.cpp:588
QWizardHeader * headerWidget
Definition qwizard.cpp:597
void updateLayout()
Definition qwizard.cpp:1203
QHBoxLayout * buttonLayout
Definition qwizard.cpp:606
void updateMinMaxSizes(const QWizardLayoutInfo &info)
Definition qwizard.cpp:1288
void _q_emitCustomButtonClicked()
Definition qwizard.cpp:1617
void setButtonLayout(const QWizard::WizardButton *array, int size)
Definition qwizard.cpp:1472
bool isVistaThemeEnabled() const
Definition qwizard.cpp:1590
void updatePixmap(QWizard::WizardPixmap which)
Definition qwizard.cpp:1510
QWidget * sideWidget
Definition qwizard.cpp:599
void _q_handleFieldObjectDestroyed(QObject *)
Definition qwizard.cpp:1680
void switchToPage(int newId, Direction direction)
Definition qwizard.cpp:768
QList< QWizard::WizardButton > buttonsCustomLayout
Definition qwizard.cpp:577
void enableUpdates()
Definition qwizard.cpp:1608
int disableUpdatesCount
Definition qwizard.cpp:571
QPixmap defaultPixmaps[QWizard::NPixmaps]
Definition qwizard.cpp:580
QWidget * placeholderWidget2
Definition qwizard.cpp:596
QWizardRuler * bottomRuler
Definition qwizard.cpp:603
Qt::TextFormat subTitleFmt
Definition qwizard.cpp:579
void updateButtonTexts()
Definition qwizard.cpp:1403
void updateButtonLayout()
Definition qwizard.cpp:1432
QList< QWizardField > fields
Definition qwizard.cpp:561
bool ensureButton(QWizard::WizardButton which) const
Definition qwizard.cpp:1364
void updatePalette()
Definition qwizard.cpp:1264
bool buttonsHaveCustomLayout
Definition qwizard.cpp:576
void cleanupPagesNotInHistory()
Definition qwizard.cpp:717
QAbstractButton * btns[QWizard::NButtons]
Definition qwizard.cpp:592
Qt::TextFormat titleFmt
Definition qwizard.cpp:578
void disableUpdates()
Definition qwizard.cpp:1599
QWidget * placeholderWidget1
Definition qwizard.cpp:595
void addField(const QWizardField &field)
Definition qwizard.cpp:731
QWizardLayoutInfo layoutInfo
Definition qwizard.cpp:570
QWizardRuler(QWidget *parent=nullptr)
Definition qwizard.cpp:414
The QWizard class provides a framework for wizards.
Definition qwizard.h:20
Combined button and popup list for selecting options.
static const char * buttonSlots(QWizard::WizardButton which)
Definition qwizard.cpp:844
static QString buttonDefaultText(int wstyle, int which, const QWizardPrivate *wizardPrivate)
Definition qwizard.cpp:625
const char className[16]
Definition qwizard.cpp:100
static QString object_name_for_button(QWizard::WizardButton which)
Definition qwizard.cpp:1338
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)