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