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 WizardOption {
65 IndependentPages = 0x00000001,
66 IgnoreSubTitles = 0x00000002,
67 ExtendedWatermarkPixmap = 0x00000004,
68 NoDefaultButton = 0x00000008,
69 NoBackButtonOnStartPage = 0x00000010,
70 NoBackButtonOnLastPage = 0x00000020,
71 DisabledBackButtonOnLastPage = 0x00000040,
72 HaveNextButtonOnLastPage = 0x00000080,
73 HaveFinishButtonOnEarlyPages = 0x00000100,
74 NoCancelButton = 0x00000200,
75 CancelButtonOnLeft = 0x00000400,
76 HaveHelpButton = 0x00000800,
77 HelpButtonOnRight = 0x00001000,
78 HaveCustomButton1 = 0x00002000,
79 HaveCustomButton2 = 0x00004000,
80 HaveCustomButton3 = 0x00008000,
81 NoCancelButtonOnLastPage = 0x00010000,
82 StretchBanner = 0x00020000,
83 };
84 Q_ENUM(WizardOption)
85
86 Q_DECLARE_FLAGS(WizardOptions, WizardOption)
87 Q_FLAG(WizardOptions)
88
89 explicit QWizard(QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags());
90 ~QWizard();
91
92 int addPage(QWizardPage *page);
93 void setPage(int id, QWizardPage *page);
94 void removePage(int id);
95 QWizardPage *page(int id) const;
96 bool hasVisitedPage(int id) const;
97 QList<int> visitedIds() const;
98 QList<int> pageIds() const;
99 void setStartId(int id);
100 int startId() const;
101 QWizardPage *currentPage() const;
102 int currentId() const;
103
104 virtual bool validateCurrentPage();
105 virtual int nextId() const;
106
107 void setField(const QString &name, const QVariant &value);
108 QVariant field(const QString &name) const;
109
110 void setWizardStyle(WizardStyle style);
111 WizardStyle wizardStyle() const;
112
113 void setOption(WizardOption option, bool on = true);
114 bool testOption(WizardOption option) const;
115 void setOptions(WizardOptions options);
116 WizardOptions options() const;
117
118 void setButtonText(WizardButton which, const QString &text);
119 QString buttonText(WizardButton which) const;
120 void setButtonLayout(const QList<WizardButton> &layout);
121 void setButton(WizardButton which, QAbstractButton *button);
122 QAbstractButton *button(WizardButton which) const;
123
124 void setTitleFormat(Qt::TextFormat format);
125 Qt::TextFormat titleFormat() const;
126 void setSubTitleFormat(Qt::TextFormat format);
127 Qt::TextFormat subTitleFormat() const;
128 void setPixmap(WizardPixmap which, const QPixmap &pixmap);
129 QPixmap pixmap(WizardPixmap which) const;
130
131 void setSideWidget(QWidget *widget);
132 QWidget *sideWidget() const;
133
134 void setDefaultProperty(const char *className, const char *property,
135 const char *changedSignal);
136
137 void setVisible(bool visible) override;
138 QSize sizeHint() const override;
139
140Q_SIGNALS:
141 void currentIdChanged(int id);
142 void helpRequested();
143 void customButtonClicked(int which);
144 void pageAdded(int id);
145 void pageRemoved(int id);
146
147public Q_SLOTS:
148 void back();
149 void next();
150 void setCurrentId(int id);
151 void restart();
152
153protected:
154 bool event(QEvent *event) override;
155 void resizeEvent(QResizeEvent *event) override;
156 void paintEvent(QPaintEvent *event) override;
157#if defined(Q_OS_WIN) || defined(Q_QDOC)
158 bool nativeEvent(const QByteArray &eventType, void *message, qintptr *result) override;
159#endif
160 void done(int result) override;
161 virtual void initializePage(int id);
162 virtual void cleanupPage(int id);
163
164private:
165 Q_DISABLE_COPY(QWizard)
166 Q_DECLARE_PRIVATE(QWizard)
167 Q_PRIVATE_SLOT(d_func(), void _q_emitCustomButtonClicked())
168 Q_PRIVATE_SLOT(d_func(), void _q_updateButtonStates())
169 Q_PRIVATE_SLOT(d_func(), void _q_handleFieldObjectDestroyed(QObject *))
170
171 friend class QWizardPage;
172};
173
174Q_DECLARE_OPERATORS_FOR_FLAGS(QWizard::WizardOptions)
175
176class QWizardPagePrivate;
177
178class Q_WIDGETS_EXPORT QWizardPage : public QWidget
179{
180 Q_OBJECT
181 Q_PROPERTY(QString title READ title WRITE setTitle)
182 Q_PROPERTY(QString subTitle READ subTitle WRITE setSubTitle)
183
184public:
185 explicit QWizardPage(QWidget *parent = nullptr);
186 ~QWizardPage();
187
188 void setTitle(const QString &title);
189 QString title() const;
190 void setSubTitle(const QString &subTitle);
191 QString subTitle() const;
192 void setPixmap(QWizard::WizardPixmap which, const QPixmap &pixmap);
193 QPixmap pixmap(QWizard::WizardPixmap which) const;
194 void setFinalPage(bool finalPage);
195 bool isFinalPage() const;
196 void setCommitPage(bool commitPage);
197 bool isCommitPage() const;
198 void setButtonText(QWizard::WizardButton which, const QString &text);
199 QString buttonText(QWizard::WizardButton which) const;
200
201 virtual void initializePage();
202 virtual void cleanupPage();
203 virtual bool validatePage();
204 virtual bool isComplete() const;
205 virtual int nextId() const;
206
207Q_SIGNALS:
208 void completeChanged();
209
210protected:
211 void setField(const QString &name, const QVariant &value);
212 QVariant field(const QString &name) const;
213 void registerField(const QString &name, QWidget *widget, const char *property = nullptr,
214 const char *changedSignal = nullptr);
215 QWizard *wizard() const;
216
217private:
218 Q_DISABLE_COPY(QWizardPage)
219 Q_DECLARE_PRIVATE(QWizardPage)
220 Q_PRIVATE_SLOT(d_func(), void _q_maybeEmitCompleteChanged())
221 Q_PRIVATE_SLOT(d_func(), void _q_updateCachedCompleteState())
222
223 friend class QWizard;
224 friend class QWizardPrivate;
225};
226
227QT_END_NAMESPACE
228
229#endif // QWIZARD_H
friend class QWidget
Definition qpainter.h:432
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:179
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)