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.cpp
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#include "qwizard.h"
6#include <QtWidgets/private/qtwidgetsglobal_p.h>
7
8#if QT_CONFIG(spinbox)
9#include "qabstractspinbox.h"
10#endif
11#include "qalgorithms.h"
12#include "qapplication.h"
13#include "qboxlayout.h"
14#include "qlayoutitem.h"
15#include "qevent.h"
16#include "qframe.h"
17#include "qlabel.h"
18#if QT_CONFIG(lineedit)
19#include "qlineedit.h"
20#endif
21#include <qpointer.h>
22#include "qstylepainter.h"
23#include "qwindow.h"
24#include "qpushbutton.h"
25#include "qset.h"
26#if QT_CONFIG(shortcut)
27# include "qshortcut.h"
28#endif
29#include "qstyle.h"
30#include "qstyleoption.h"
32#if defined(Q_OS_MACOS)
33#include <AppKit/AppKit.h>
34#include <QtGui/private/qcoregraphics_p.h>
35#elif QT_CONFIG(style_windowsvista)
36#include "qwizard_win_p.h"
37#endif
38
39#include "private/qdialog_p.h"
40
41#include <qdebug.h>
42#include <QtCore/private/qenumindexedarray_p.h>
43
44#include <string.h> // for memset()
45#include <algorithm>
46
48
49using namespace Qt::StringLiterals;
50
51// These fudge terms were needed a few places to obtain pixel-perfect results
54const int ClassicHMargin = 4;
55const int MacButtonTopMargin = 13;
56const int MacLayoutLeftMargin = 20;
57//const int MacLayoutTopMargin = 14; // Unused. Save some space and avoid warning.
58const int MacLayoutRightMargin = 20;
59const int MacLayoutBottomMargin = 17;
60
61static void changeSpacerSize(QLayout *layout, int index, int width, int height)
62{
63 QSpacerItem *spacer = layout->itemAt(index)->spacerItem();
64 if (!spacer)
65 return;
66 spacer->changeSize(width, height);
67}
68
69static QWidget *iWantTheFocus(QWidget *ancestor)
70{
71 const int MaxIterations = 100;
72
73 QWidget *candidate = ancestor;
74 for (int i = 0; i < MaxIterations; ++i) {
75 candidate = candidate->nextInFocusChain();
76 if (!candidate)
77 break;
78
79 if (candidate->focusPolicy() & Qt::TabFocus) {
80 if (candidate != ancestor && ancestor->isAncestorOf(candidate))
81 return candidate;
82 }
83 }
84 return nullptr;
85}
86
87static bool objectInheritsXAndXIsCloserThanY(const QObject *object, const QByteArray &classX,
88 const QByteArray &classY)
89{
90 const QMetaObject *metaObject = object->metaObject();
91 while (metaObject) {
92 if (metaObject->className() == classX)
93 return true;
94 if (metaObject->className() == classY)
95 return false;
96 metaObject = metaObject->superClass();
97 }
98 return false;
99}
100
101const struct {
102 const char className[16];
103 const char property[13];
104} fallbackProperties[] = {
105 // If you modify this list, make sure to update the documentation (and the auto test)
106 { "QAbstractButton", "checked" },
107 { "QAbstractSlider", "value" },
108 { "QComboBox", "currentIndex" },
109 { "QDateTimeEdit", "dateTime" },
110 { "QLineEdit", "text" },
111 { "QListWidget", "currentRow" },
112 { "QSpinBox", "value" },
114const size_t NFallbackDefaultProperties = sizeof fallbackProperties / sizeof *fallbackProperties;
115
116static const char *changed_signal(int which)
117{
118 // since it might expand to a runtime function call (to
119 // qFlagLocations()), we cannot store the result of SIGNAL() in a
120 // character array and expect it to be statically initialized. To
121 // avoid the relocations caused by a char pointer table, use a
122 // switch statement:
123 switch (which) {
124 case 0: return SIGNAL(toggled(bool));
125 case 1: return SIGNAL(valueChanged(int));
126 case 2: return SIGNAL(currentIndexChanged(int));
127 case 3: return SIGNAL(dateTimeChanged(QDateTime));
128 case 4: return SIGNAL(textChanged(QString));
129 case 5: return SIGNAL(currentRowChanged(int));
130 case 6: return SIGNAL(valueChanged(int));
131 };
132 static_assert(7 == NFallbackDefaultProperties);
133 Q_UNREACHABLE_RETURN(nullptr);
134}
135
137{
138public:
142
144 inline QWizardDefaultProperty(const char *className, const char *property,
145 const char *changedSignal)
147};
149
151{
152public:
153 inline QWizardField() {}
154 QWizardField(QWizardPage *page, const QString &spec, QObject *object, const char *property,
155 const char *changedSignal);
156
157 void resolve(const QList<QWizardDefaultProperty> &defaultPropertyTable);
158 void findProperty(const QWizardDefaultProperty *properties, int propertyCount);
159
160 QWizardPage *page;
166 QVariant initialValue;
167};
169
170QWizardField::QWizardField(QWizardPage *page, const QString &spec, QObject *object,
171 const char *property, const char *changedSignal)
172 : page(page), name(spec), mandatory(false), object(object), property(property),
174{
175 if (name.endsWith(u'*')) {
176 name.chop(1);
177 mandatory = true;
178 }
179}
180
181void QWizardField::resolve(const QList<QWizardDefaultProperty> &defaultPropertyTable)
182{
183 if (property.isEmpty())
184 findProperty(defaultPropertyTable.constData(), defaultPropertyTable.size());
185 initialValue = object->property(property);
186}
187
188void QWizardField::findProperty(const QWizardDefaultProperty *properties, int propertyCount)
189{
190 QByteArray className;
191
192 for (int i = 0; i < propertyCount; ++i) {
193 if (objectInheritsXAndXIsCloserThanY(object, properties[i].className, className)) {
194 className = properties[i].className;
195 property = properties[i].property;
196 changedSignal = properties[i].changedSignal;
197 }
198 }
199}
200
202{
203public:
212 int hspacing = -1;
213 int vspacing = -1;
216 bool header = false;
217 bool watermark = false;
218 bool title = false;
219 bool subTitle = false;
220 bool extension = false;
221 bool sideWidget = false;
222
223 bool operator==(const QWizardLayoutInfo &other) const;
224 inline bool operator!=(const QWizardLayoutInfo &other) const { return !operator==(other); }
225};
226
228{
229 return topLevelMarginLeft == other.topLevelMarginLeft
230 && topLevelMarginRight == other.topLevelMarginRight
231 && topLevelMarginTop == other.topLevelMarginTop
232 && topLevelMarginBottom == other.topLevelMarginBottom
233 && childMarginLeft == other.childMarginLeft
234 && childMarginRight == other.childMarginRight
235 && childMarginTop == other.childMarginTop
236 && childMarginBottom == other.childMarginBottom
237 && hspacing == other.hspacing
238 && vspacing == other.vspacing
239 && buttonSpacing == other.buttonSpacing
240 && wizStyle == other.wizStyle
241 && header == other.header
242 && watermark == other.watermark
243 && title == other.title
244 && subTitle == other.subTitle
245 && extension == other.extension
246 && sideWidget == other.sideWidget;
247}
248
249class QWizardHeader : public QWidget
250{
251protected:
252 enum RulerType { Ruler };
253
254 explicit
255 inline QWizardHeader(RulerType /* ruler */, QWidget *parent = nullptr)
256 : QWidget(parent) { setFixedHeight(2); }
257public:
258 explicit
259 QWizardHeader(QWidget *parent = nullptr);
260
261 void setup(const QWizardLayoutInfo &info, const QString &title,
262 const QString &subTitle, const QPixmap &logo, const QPixmap &banner,
263 std::optional<Qt::TextFormat> titleFormat,
264 std::optional<Qt::TextFormat> subTitleFormat,
265 QWizard::WizardOptions wizardOptions);
266
267protected:
268 void paintEvent(QPaintEvent *event) override;
269#if QT_CONFIG(style_windowsvista)
270private:
271 bool vistaDisabled() const;
272#endif
273private:
274 QLabel *titleLabel;
275 QLabel *subTitleLabel;
276 QLabel *logoLabel;
277 QGridLayout *layout;
278 QPixmap bannerPixmap;
280};
281
283 : QWidget(parent)
284{
285 setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
286 setBackgroundRole(QPalette::Base);
287
288 titleLabel = new QLabel(this);
289 titleLabel->setBackgroundRole(QPalette::Base);
290
291 subTitleLabel = new QLabel(this);
292 subTitleLabel->setAlignment(Qt::AlignTop | Qt::AlignLeft);
293 subTitleLabel->setWordWrap(true);
294
295 logoLabel = new QLabel(this);
296
297 QFont font = titleLabel->font();
298 font.setBold(true);
299 titleLabel->setFont(font);
300
301 layout = new QGridLayout(this);
302 layout->setContentsMargins(QMargins());
303 layout->setSpacing(0);
304
305 layout->setRowMinimumHeight(3, 1);
306 layout->setRowStretch(4, 1);
307
308 layout->setColumnStretch(2, 1);
309 layout->setColumnMinimumWidth(4, 2 * GapBetweenLogoAndRightEdge);
310 layout->setColumnMinimumWidth(6, GapBetweenLogoAndRightEdge);
311
312 layout->addWidget(titleLabel, 2, 1, 1, 2);
313 layout->addWidget(subTitleLabel, 4, 2);
314 layout->addWidget(logoLabel, 1, 5, 5, 1);
315}
316
317#if QT_CONFIG(style_windowsvista)
318bool QWizardHeader::vistaDisabled() const
319{
320 bool styleDisabled = false;
321 QWizard *wiz = parentWidget() ? qobject_cast <QWizard *>(parentWidget()->parentWidget()) : 0;
322 if (wiz) {
323 // Designer doesn't support the Vista style for Wizards. This property is used to turn
324 // off the Vista style.
325 const QVariant v = wiz->property("_q_wizard_vista_off");
326 styleDisabled = v.isValid() && v.toBool();
327 }
328 return styleDisabled;
329}
330#endif
331
332void QWizardHeader::setup(const QWizardLayoutInfo &info, const QString &title,
333 const QString &subTitle, const QPixmap &logo, const QPixmap &banner,
334 std::optional<Qt::TextFormat> titleFormat,
335 std::optional<Qt::TextFormat> subTitleFormat,
336 QWizard::WizardOptions options)
337{
338 bool modern = ((info.wizStyle == QWizard::ModernStyle)
339#if QT_CONFIG(style_windowsvista)
340 || vistaDisabled()
341#endif
342 );
343 wizardOptions = options;
344 layout->setRowMinimumHeight(0, modern ? ModernHeaderTopMargin : 0);
345 layout->setRowMinimumHeight(1, modern ? info.topLevelMarginTop - ModernHeaderTopMargin - 1 : 0);
346 layout->setRowMinimumHeight(6, (modern ? 3 : GapBetweenLogoAndRightEdge) + 2);
347
348 int minColumnWidth0 = modern ? info.topLevelMarginLeft + info.topLevelMarginRight : 0;
349 int minColumnWidth1 = modern ? info.topLevelMarginLeft + info.topLevelMarginRight + 1
351 layout->setColumnMinimumWidth(0, minColumnWidth0);
352 layout->setColumnMinimumWidth(1, minColumnWidth1);
353
354 if (titleFormat)
355 titleLabel->setTextFormat(titleFormat.value());
356 titleLabel->setText(title);
357 logoLabel->setPixmap(logo);
358
359 if (subTitleFormat)
360 subTitleLabel->setTextFormat(subTitleFormat.value());
361 subTitleLabel->setText("Pq\nPq"_L1);
362 int desiredSubTitleHeight = subTitleLabel->sizeHint().height();
363 subTitleLabel->setText(subTitle);
364
365 if (modern) {
366 bannerPixmap = banner;
367 } else {
368 bannerPixmap = QPixmap();
369 }
370
371 if (bannerPixmap.isNull() || wizardOptions.testFlag(QWizard::StretchBanner)) {
372 /*
373 There is no widthForHeight() function, so we simulate it with a loop.
374 */
375 int candidateSubTitleWidth = qMin(512, 2 * QGuiApplication::primaryScreen()->virtualGeometry().width() / 3);
376 int delta = candidateSubTitleWidth >> 1;
377 while (delta > 0) {
378 if (subTitleLabel->heightForWidth(candidateSubTitleWidth - delta)
379 <= desiredSubTitleHeight)
380 candidateSubTitleWidth -= delta;
381 delta >>= 1;
382 }
383
384 subTitleLabel->setMinimumSize(candidateSubTitleWidth, desiredSubTitleHeight);
385
386 QSize size = layout->totalMinimumSize();
387 setMinimumSize(size);
388 setMaximumSize(QWIDGETSIZE_MAX, size.height());
389 } else {
390 subTitleLabel->setMinimumSize(0, 0);
391 setFixedSize(banner.size() + QSize(0, 2));
392 }
393 updateGeometry();
394}
395
396void QWizardHeader::paintEvent(QPaintEvent * /* event */)
397{
398 QStylePainter painter(this);
399 if (wizardOptions.testFlag(QWizard::StretchBanner)) {
400 painter.setRenderHint(QPainter::SmoothPixmapTransform);
401 painter.drawPixmap(0, 0, width(), height(), bannerPixmap);
402 } else {
403 painter.drawPixmap(0, 0, bannerPixmap);
404 }
405
406 // With fractional scaling the 1px difference in y-coordinate can map to
407 // the same pixel, so make sure that we take DPR into account when drawing
408 // the lines.
409 const qreal dpr = devicePixelRatio();
410 const int devHeight = qRound(height() * dpr);
411 const int devWidth = qRound(width() * dpr);
412
413 const qreal x = (devWidth - 2) / dpr;
414 const qreal y = (devHeight - 2) / dpr;
415
416 const qreal x1 = (devWidth - 1) / dpr;
417 const qreal y1 = (devHeight - 1) / dpr;
418
419 const QPalette &pal = palette();
420 painter.setPen(pal.mid().color());
421 painter.drawLine(QLineF(0, y, x, y));
422 painter.setPen(pal.base().color());
423 painter.drawPoint(QPointF(x1, y));
424 painter.drawLine(QLineF(0, y1, x1, y1));
425}
426
427// We save one vtable by basing QWizardRuler on QWizardHeader
429{
430public:
431 inline QWizardRuler(QWidget *parent = nullptr)
432 : QWizardHeader(Ruler, parent) {}
433};
434
436{
437public:
438 QWatermarkLabel(QWidget *parent, QWidget *sideWidget) : QLabel(parent), m_sideWidget(sideWidget) {
439 m_layout = new QVBoxLayout(this);
440 if (m_sideWidget)
441 m_layout->addWidget(m_sideWidget);
442 }
443
444 QSize minimumSizeHint() const override {
445 if (!pixmap().isNull())
446 return pixmap().deviceIndependentSize().toSize();
447 return QLabel::minimumSizeHint();
448 }
449
450 void setSideWidget(QWidget *widget) {
451 if (m_sideWidget == widget)
452 return;
453 if (m_sideWidget) {
454 m_layout->removeWidget(m_sideWidget);
455 m_sideWidget->hide();
456 }
457 m_sideWidget = widget;
458 if (m_sideWidget)
459 m_layout->addWidget(m_sideWidget);
460 }
462 return m_sideWidget;
463 }
464private:
465 QVBoxLayout *m_layout;
466 QWidget *m_sideWidget;
467};
468
491
493{
494 Q_Q(const QWizardPage);
495 if (completeState == Tri_Unknown)
496 completeState = q->isComplete() ? Tri_True : Tri_False;
497 return completeState == Tri_True;
498}
499
501{
502 Q_Q(QWizardPage);
503 TriState newState = q->isComplete() ? Tri_True : Tri_False;
504 if (newState != completeState)
505 emit q->completeChanged();
506}
507
509{
510 Q_Q(QWizardPage);
511 completeState = q->isComplete() ? Tri_True : Tri_False;
512}
513
515{
516public:
517#if QT_CONFIG(style_windowsvista)
520 : QWidget(wizard)
522protected:
524#else
526 : QWidget(wizard)
527 {}
528#endif
529};
530
532{
533 Q_DECLARE_PUBLIC(QWizard)
534
535public:
536 typedef QMap<int, QWizardPage *> PageMap;
537
542
543 void init();
544 void reset();
546 void addField(const QWizardField &field);
547 void removeFieldAt(int index);
548 void switchToPage(int newId, Direction direction);
555 bool ensureButton(QWizard::WizardButton which) const;
556 void connectButton(QWizard::WizardButton which) const;
559 void setButtonLayout(const QWizard::WizardButton *array, int size);
560 bool buttonLayoutContains(QWizard::WizardButton which);
561 void updatePixmap(QWizard::WizardPixmap which);
562#if QT_CONFIG(style_windowsvista)
563 bool vistaDisabled() const;
565#endif
572 void setStyle(QStyle *style);
573#ifdef Q_OS_MACOS
575#endif
576
582 int start = -1;
583 bool startSetByUser = false;
584 int current = -1;
585 bool canContinue = false;
586 bool canFinish = false;
589
598
599 union {
600 // keep in sync with QWizard::WizardButton
601 mutable struct {
602 QAbstractButton *back;
603 QAbstractButton *next;
604 QAbstractButton *commit;
605 QAbstractButton *finish;
606 QAbstractButton *cancel;
607 QAbstractButton *help;
608 } btn;
609 mutable QAbstractButton *btns[QWizard::NButtons];
610 };
616 QWidget *sideWidget = nullptr;
617 QFrame *pageFrame = nullptr;
618 QLabel *titleLabel = nullptr;
621
625
626#if QT_CONFIG(style_windowsvista)
627 QVistaHelper *vistaHelper = nullptr;
628# if QT_CONFIG(shortcut)
630# endif
631 bool vistaInitPending = false;
632 bool vistaDirty = true;
633 bool vistaStateChanged = false;
634 bool inHandleAeroStyleChange = false;
635#endif
640};
641
642static QString buttonDefaultText(int wstyle, int which, const QWizardPrivate *wizardPrivate)
643{
644#if !QT_CONFIG(style_windowsvista)
645 Q_UNUSED(wizardPrivate);
646#endif
647 const bool macStyle = (wstyle == QWizard::MacStyle);
648 switch (which) {
649 case QWizard::BackButton:
650 return macStyle ? QWizard::tr("Go Back") : QWizard::tr("< &Back");
651 case QWizard::NextButton:
652 if (macStyle)
653 return QWizard::tr("Continue");
654 else
655 return wizardPrivate->isVistaThemeEnabled()
656 ? QWizard::tr("&Next") : QWizard::tr("&Next >");
657 case QWizard::CommitButton:
658 return QWizard::tr("Commit");
659 case QWizard::FinishButton:
660 return macStyle ? QWizard::tr("Done") : QWizard::tr("&Finish");
661 case QWizard::CancelButton:
662 return QWizard::tr("Cancel");
663 case QWizard::HelpButton:
664 return macStyle ? QWizard::tr("Help") : QWizard::tr("&Help");
665 default:
666 return QString();
667 }
668}
669
671{
672 Q_Q(QWizard);
673
674 std::fill(btns, btns + QWizard::NButtons, nullptr);
675
676 antiFlickerWidget = new QWizardAntiFlickerWidget(q, this);
677 wizStyle = QWizard::WizardStyle(q->style()->styleHint(QStyle::SH_WizardStyle, nullptr, q));
678 switch (wizStyle) {
679 case QWizard::ModernStyle:
680 opts = QWizard::HelpButtonOnRight;
681 break;
682 case QWizard::MacStyle:
683 opts = (QWizard::NoDefaultButton | QWizard::NoCancelButton);
684 break;
685#if QT_CONFIG(style_windowsvista)
686 case QWizard::AeroStyle:
687 vistaInitPending = true;
688#endif
689 default:
690 break;
691 }
692
693#if QT_CONFIG(style_windowsvista)
694 vistaHelper = new QVistaHelper(q);
695#endif
696
697 // create these buttons right away; create the other buttons as necessary
698 ensureButton(QWizard::BackButton);
699 ensureButton(QWizard::NextButton);
700 ensureButton(QWizard::CommitButton);
701 ensureButton(QWizard::FinishButton);
702
703 pageFrame = new QFrame(antiFlickerWidget);
704 pageFrame->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
705
706 pageVBoxLayout = new QVBoxLayout(pageFrame);
707 pageVBoxLayout->setSpacing(0);
708 pageVBoxLayout->addSpacing(0);
709 QSpacerItem *spacerItem = new QSpacerItem(0, 0, QSizePolicy::Ignored, QSizePolicy::MinimumExpanding);
710 pageVBoxLayout->addItem(spacerItem);
711
712 buttonLayout = new QHBoxLayout;
713 mainLayout = new QGridLayout(antiFlickerWidget);
714 mainLayout->setSizeConstraint(QLayout::SetNoConstraint);
715
717
718 defaultPropertyTable.reserve(NFallbackDefaultProperties);
719 for (uint i = 0; i < NFallbackDefaultProperties; ++i)
720 defaultPropertyTable.append(QWizardDefaultProperty(fallbackProperties[i].className,
721 fallbackProperties[i].property,
722 changed_signal(i)));
723}
724
726{
727 Q_Q(QWizard);
728 if (current != -1) {
729 q->currentPage()->hide();
731 const auto end = history.crend();
732 for (auto it = history.crbegin(); it != end; ++it)
733 q->cleanupPage(*it);
734 history.clear();
735 for (QWizardPage *page : std::as_const(pageMap))
736 page->d_func()->initialized = false;
737
738 current = -1;
739 emit q->currentIdChanged(-1);
740 }
741}
742
744{
745 Q_Q(QWizard);
746
747 for (auto it = pageMap.begin(), end = pageMap.end(); it != end; ++it) {
748 const auto idx = it.key();
749 const auto page = it.value()->d_func();
750 if (page->initialized && !history.contains(idx)) {
751 q->cleanupPage(idx);
752 page->initialized = false;
753 }
754 }
755}
756
758{
759 Q_Q(QWizard);
760
761 QWizardField myField = field;
762 myField.resolve(defaultPropertyTable);
763
764 if (Q_UNLIKELY(fieldIndexMap.contains(myField.name))) {
765 qWarning("QWizardPage::addField: Duplicate field '%ls'", qUtf16Printable(myField.name));
766 return;
767 }
768
769 fieldIndexMap.insert(myField.name, fields.size());
770 fields += myField;
771 if (myField.mandatory && !myField.changedSignal.isEmpty())
772 QObject::connect(myField.object, myField.changedSignal,
773 myField.page, SLOT(_q_maybeEmitCompleteChanged()));
774 QObject::connect(
775 myField.object, SIGNAL(destroyed(QObject*)), q,
776 SLOT(_q_handleFieldObjectDestroyed(QObject*)));
777}
778
780{
781 Q_Q(QWizard);
782
783 const QWizardField &field = fields.at(index);
784 fieldIndexMap.remove(field.name);
785 if (field.mandatory && !field.changedSignal.isEmpty())
786 QObject::disconnect(field.object, field.changedSignal,
787 field.page, SLOT(_q_maybeEmitCompleteChanged()));
788 QObject::disconnect(
789 field.object, SIGNAL(destroyed(QObject*)), q,
790 SLOT(_q_handleFieldObjectDestroyed(QObject*)));
791 fields.remove(index);
792}
793
794void QWizardPrivate::switchToPage(int newId, Direction direction)
795{
796 Q_Q(QWizard);
797
799
800 int oldId = current;
801 if (QWizardPage *oldPage = q->currentPage()) {
802 oldPage->hide();
803
804 if (direction == Backward) {
805 if (!(opts & QWizard::IndependentPages)) {
806 q->cleanupPage(oldId);
807 oldPage->d_func()->initialized = false;
808 }
809 Q_ASSERT(history.constLast() == oldId);
810 history.removeLast();
811 Q_ASSERT(history.constLast() == newId);
812 }
813 }
814
815 current = newId;
816
817 QWizardPage *newPage = q->currentPage();
818 if (newPage) {
819 if (direction == Forward) {
820 if (!newPage->d_func()->initialized) {
821 newPage->d_func()->initialized = true;
822 q->initializePage(current);
823 }
824 history.append(current);
825 }
826 newPage->show();
827 }
828
829 canContinue = (q->nextId() != -1);
830 canFinish = (newPage && newPage->isFinalPage());
831
834
835 const QWizard::WizardButton nextOrCommit =
836 newPage && newPage->isCommitPage() ? QWizard::CommitButton : QWizard::NextButton;
837 QAbstractButton *nextOrFinishButton =
838 btns[canContinue ? nextOrCommit : QWizard::FinishButton];
839 QWidget *candidate = nullptr;
840
841 /*
842 If there is no default button and the Next or Finish button
843 is enabled, give focus directly to it as a convenience to the
844 user. This is the normal case on OS X.
845
846 Otherwise, give the focus to the new page's first child that
847 can handle it. If there is no such child, give the focus to
848 Next or Finish.
849 */
850 if ((opts & QWizard::NoDefaultButton) && nextOrFinishButton->isEnabled()) {
851 candidate = nextOrFinishButton;
852 } else if (newPage) {
853 candidate = iWantTheFocus(newPage);
854 }
855 if (!candidate)
856 candidate = nextOrFinishButton;
857 candidate->setFocus();
858
859 if (wizStyle == QWizard::MacStyle)
860 q->updateGeometry();
861
865
866 emit q->currentIdChanged(current);
867}
868
869// keep in sync with QWizard::WizardButton
870static const char * buttonSlots(QWizard::WizardButton which)
871{
872 switch (which) {
873 case QWizard::BackButton:
874 return SLOT(back());
875 case QWizard::NextButton:
876 case QWizard::CommitButton:
877 return SLOT(next());
878 case QWizard::FinishButton:
879 return SLOT(accept());
880 case QWizard::CancelButton:
881 return SLOT(reject());
882 case QWizard::HelpButton:
883 return SIGNAL(helpRequested());
884 case QWizard::CustomButton1:
885 case QWizard::CustomButton2:
886 case QWizard::CustomButton3:
887 case QWizard::Stretch:
888 case QWizard::NoButton:
889 Q_UNREACHABLE();
890 };
891 return nullptr;
892};
893
895{
896 Q_Q(QWizard);
897 QStyle *style = q->style();
898
900
901 QStyleOption option;
902 option.initFrom(q);
903 const int layoutHorizontalSpacing = style->pixelMetric(QStyle::PM_LayoutHorizontalSpacing, &option, q);
904 info.topLevelMarginLeft = style->pixelMetric(QStyle::PM_LayoutLeftMargin, nullptr, q);
905 info.topLevelMarginRight = style->pixelMetric(QStyle::PM_LayoutRightMargin, nullptr, q);
906 info.topLevelMarginTop = style->pixelMetric(QStyle::PM_LayoutTopMargin, nullptr, q);
907 info.topLevelMarginBottom = style->pixelMetric(QStyle::PM_LayoutBottomMargin, nullptr, q);
908 info.childMarginLeft = style->pixelMetric(QStyle::PM_LayoutLeftMargin, nullptr, titleLabel);
909 info.childMarginRight = style->pixelMetric(QStyle::PM_LayoutRightMargin, nullptr, titleLabel);
910 info.childMarginTop = style->pixelMetric(QStyle::PM_LayoutTopMargin, nullptr, titleLabel);
911 info.childMarginBottom = style->pixelMetric(QStyle::PM_LayoutBottomMargin, nullptr, titleLabel);
912 info.hspacing = (layoutHorizontalSpacing == -1)
913 ? style->layoutSpacing(QSizePolicy::DefaultType, QSizePolicy::DefaultType, Qt::Horizontal)
914 : layoutHorizontalSpacing;
915 info.vspacing = style->pixelMetric(QStyle::PM_LayoutVerticalSpacing, &option, q);
916 info.buttonSpacing = (layoutHorizontalSpacing == -1)
917 ? style->layoutSpacing(QSizePolicy::PushButton, QSizePolicy::PushButton, Qt::Horizontal)
918 : layoutHorizontalSpacing;
919
920 if (wizStyle == QWizard::MacStyle)
921 info.buttonSpacing = 12;
922
923 info.wizStyle = wizStyle;
924 if (info.wizStyle == QWizard::AeroStyle
925#if QT_CONFIG(style_windowsvista)
926 && vistaDisabled()
927#endif
928 )
929 info.wizStyle = QWizard::ModernStyle;
930
931 QString titleText;
932 QString subTitleText;
933 QPixmap backgroundPixmap;
934 QPixmap watermarkPixmap;
935
936 if (QWizardPage *page = q->currentPage()) {
937 titleText = page->title();
938 subTitleText = page->subTitle();
939 backgroundPixmap = page->pixmap(QWizard::BackgroundPixmap);
940 watermarkPixmap = page->pixmap(QWizard::WatermarkPixmap);
941 }
942
943 info.header = (info.wizStyle == QWizard::ClassicStyle || info.wizStyle == QWizard::ModernStyle)
944 && !(opts & QWizard::IgnoreSubTitles) && !subTitleText.isEmpty();
946 info.watermark = (info.wizStyle != QWizard::MacStyle) && (info.wizStyle != QWizard::AeroStyle)
947 && !watermarkPixmap.isNull();
948 info.title = !info.header && !titleText.isEmpty();
949 info.subTitle = !(opts & QWizard::IgnoreSubTitles) && !info.header && !subTitleText.isEmpty();
950 info.extension = (info.watermark || info.sideWidget) && (opts & QWizard::ExtendedWatermarkPixmap);
951
952 return info;
953}
954
956{
957 Q_Q(QWizard);
958
959 /*
960 Start by undoing the main layout.
961 */
962 for (int i = mainLayout->count() - 1; i >= 0; --i) {
963 QLayoutItem *item = mainLayout->takeAt(i);
964 if (item->layout()) {
965 item->layout()->setParent(nullptr);
966 } else {
967 delete item;
968 }
969 }
970 for (int i = mainLayout->columnCount() - 1; i >= 0; --i)
971 mainLayout->setColumnMinimumWidth(i, 0);
972 for (int i = mainLayout->rowCount() - 1; i >= 0; --i)
973 mainLayout->setRowMinimumHeight(i, 0);
974
975 /*
976 Now, recreate it.
977 */
978
979 bool mac = (info.wizStyle == QWizard::MacStyle);
980 bool classic = (info.wizStyle == QWizard::ClassicStyle);
981 bool modern = (info.wizStyle == QWizard::ModernStyle);
982 bool aero = (info.wizStyle == QWizard::AeroStyle);
983 int deltaMarginLeft = info.topLevelMarginLeft - info.childMarginLeft;
984 int deltaMarginRight = info.topLevelMarginRight - info.childMarginRight;
985 int deltaMarginTop = info.topLevelMarginTop - info.childMarginTop;
986 int deltaMarginBottom = info.topLevelMarginBottom - info.childMarginBottom;
987 int deltaVSpacing = info.topLevelMarginBottom - info.vspacing;
988
989 int row = 0;
990 int numColumns;
991 if (mac) {
992 numColumns = 3;
993 } else if (info.watermark || info.sideWidget) {
994 numColumns = 2;
995 } else {
996 numColumns = 1;
997 }
998 int pageColumn = qMin(1, numColumns - 1);
999
1000 if (mac) {
1001 mainLayout->setContentsMargins(QMargins());
1002 mainLayout->setSpacing(0);
1003 buttonLayout->setContentsMargins(MacLayoutLeftMargin, MacButtonTopMargin, MacLayoutRightMargin, MacLayoutBottomMargin);
1004 pageVBoxLayout->setContentsMargins(7, 7, 7, 7);
1005 } else {
1006 if (modern) {
1007 mainLayout->setContentsMargins(QMargins());
1008 mainLayout->setSpacing(0);
1009 pageVBoxLayout->setContentsMargins(deltaMarginLeft, deltaMarginTop,
1010 deltaMarginRight, deltaMarginBottom);
1011 buttonLayout->setContentsMargins(info.topLevelMarginLeft, info.topLevelMarginTop,
1012 info.topLevelMarginRight, info.topLevelMarginBottom);
1013 } else {
1014 mainLayout->setContentsMargins(info.topLevelMarginLeft, info.topLevelMarginTop,
1015 info.topLevelMarginRight, info.topLevelMarginBottom);
1016 mainLayout->setHorizontalSpacing(info.hspacing);
1017 mainLayout->setVerticalSpacing(info.vspacing);
1018 pageVBoxLayout->setContentsMargins(0, 0, 0, 0);
1019 buttonLayout->setContentsMargins(0, 0, 0, 0);
1020 }
1021 }
1022 buttonLayout->setSpacing(info.buttonSpacing);
1023
1024 if (info.header) {
1025 if (!headerWidget)
1026 headerWidget = new QWizardHeader(antiFlickerWidget);
1027 headerWidget->setAutoFillBackground(modern);
1028 mainLayout->addWidget(headerWidget, row++, 0, 1, numColumns);
1029 }
1030 if (headerWidget)
1031 headerWidget->setVisible(info.header);
1032
1033 int watermarkStartRow = row;
1034
1035 if (mac)
1036 mainLayout->setRowMinimumHeight(row++, 10);
1037
1038 if (info.title) {
1039 if (!titleLabel) {
1040 titleLabel = new QLabel(antiFlickerWidget);
1041 titleLabel->setBackgroundRole(QPalette::Base);
1042 titleLabel->setWordWrap(true);
1043 }
1044
1045 QFont titleFont = q->font();
1046 titleFont.setPointSizeF(QFontInfo(titleFont).pointSizeF() + (mac ? 3 : 4));
1047 titleFont.setBold(true);
1048 titleLabel->setPalette(QPalette());
1049
1050 if (aero) {
1051 // ### hardcoded for now:
1052 titleFont = QFont("Segoe UI"_L1, 12);
1053 QPalette pal(titleLabel->palette());
1054 pal.setColor(QPalette::Text, QColor(0x00, 0x33, 0x99));
1055 titleLabel->setPalette(pal);
1056 }
1057
1058 titleLabel->setFont(titleFont);
1059 const int aeroTitleIndent = 25; // ### hardcoded for now - should be calculated somehow
1060 if (aero)
1061 titleLabel->setIndent(aeroTitleIndent);
1062 else if (mac)
1063 titleLabel->setIndent(2);
1064 else if (classic)
1065 titleLabel->setIndent(info.childMarginLeft);
1066 else
1067 titleLabel->setIndent(info.topLevelMarginLeft);
1068 if (modern) {
1069 if (!placeholderWidget1) {
1070 placeholderWidget1 = new QWidget(antiFlickerWidget);
1071 placeholderWidget1->setBackgroundRole(QPalette::Base);
1072 }
1073 placeholderWidget1->setFixedHeight(info.topLevelMarginLeft + 2);
1074 mainLayout->addWidget(placeholderWidget1, row++, pageColumn);
1075 }
1076 mainLayout->addWidget(titleLabel, row++, pageColumn);
1077 if (modern) {
1078 if (!placeholderWidget2) {
1079 placeholderWidget2 = new QWidget(antiFlickerWidget);
1080 placeholderWidget2->setBackgroundRole(QPalette::Base);
1081 }
1082 placeholderWidget2->setFixedHeight(5);
1083 mainLayout->addWidget(placeholderWidget2, row++, pageColumn);
1084 }
1085 if (mac)
1086 mainLayout->setRowMinimumHeight(row++, 7);
1087 }
1089 placeholderWidget1->setVisible(info.title && modern);
1091 placeholderWidget2->setVisible(info.title && modern);
1092
1093 if (info.subTitle) {
1094 if (!subTitleLabel) {
1095 subTitleLabel = new QLabel(pageFrame);
1096 subTitleLabel->setWordWrap(true);
1097
1098 subTitleLabel->setContentsMargins(info.childMarginLeft , 0,
1099 info.childMarginRight , 0);
1100
1101 pageVBoxLayout->insertWidget(1, subTitleLabel);
1102 }
1103 }
1104
1105 // ### try to replace with margin.
1106 changeSpacerSize(pageVBoxLayout, 0, 0, info.subTitle ? info.childMarginLeft : 0);
1107
1108 int hMargin = mac ? 1 : 0;
1109 int vMargin = hMargin;
1110
1111 pageFrame->setFrameStyle(mac ? (QFrame::Box | QFrame::Raised) : QFrame::NoFrame);
1112 pageFrame->setLineWidth(0);
1113 pageFrame->setMidLineWidth(hMargin);
1114
1115 if (info.header) {
1116 if (modern) {
1117 hMargin = info.topLevelMarginLeft;
1118 vMargin = deltaMarginBottom;
1119 } else if (classic) {
1120 hMargin = deltaMarginLeft + ClassicHMargin;
1121 vMargin = 0;
1122 }
1123 }
1124
1125 if (aero) {
1126 int leftMargin = 18; // ### hardcoded for now - should be calculated somehow
1127 int topMargin = vMargin;
1128 int rightMargin = hMargin; // ### for now
1129 int bottomMargin = vMargin;
1130 pageFrame->setContentsMargins(leftMargin, topMargin, rightMargin, bottomMargin);
1131 } else {
1132 pageFrame->setContentsMargins(hMargin, vMargin, hMargin, vMargin);
1133 }
1134
1135 if ((info.watermark || info.sideWidget) && !watermarkLabel) {
1136 watermarkLabel = new QWatermarkLabel(antiFlickerWidget, sideWidget);
1137 watermarkLabel->setBackgroundRole(QPalette::Base);
1138 watermarkLabel->setMinimumHeight(1);
1139 watermarkLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
1140 watermarkLabel->setAlignment(Qt::AlignLeft | Qt::AlignTop);
1141 }
1142
1143 //bool wasSemiTransparent = pageFrame->testAttribute(Qt::WA_SetPalette);
1144 const bool wasSemiTransparent =
1145 pageFrame->palette().brush(QPalette::Window).color().alpha() < 255
1146 || pageFrame->palette().brush(QPalette::Base).color().alpha() < 255;
1147 if (mac) {
1148 pageFrame->setAutoFillBackground(true);
1149 antiFlickerWidget->setAutoFillBackground(false);
1150 } else {
1151 if (wasSemiTransparent)
1152 pageFrame->setPalette(QPalette());
1153
1154 bool baseBackground = (modern && !info.header); // ### TAG1
1155 pageFrame->setBackgroundRole(baseBackground ? QPalette::Base : QPalette::Window);
1156
1157 if (titleLabel)
1158 titleLabel->setAutoFillBackground(baseBackground);
1159 pageFrame->setAutoFillBackground(baseBackground);
1160 if (watermarkLabel)
1161 watermarkLabel->setAutoFillBackground(baseBackground);
1163 placeholderWidget1->setAutoFillBackground(baseBackground);
1165 placeholderWidget2->setAutoFillBackground(baseBackground);
1166
1167 if (aero) {
1168 QPalette pal = pageFrame->palette();
1169 pal.setBrush(QPalette::Window, QColor(255, 255, 255));
1170 pageFrame->setPalette(pal);
1171 pageFrame->setAutoFillBackground(true);
1172 pal = antiFlickerWidget->palette();
1173 pal.setBrush(QPalette::Window, QColor(255, 255, 255));
1174 antiFlickerWidget->setPalette(pal);
1175 antiFlickerWidget->setAutoFillBackground(true);
1176 }
1177 }
1178
1179 mainLayout->addWidget(pageFrame, row++, pageColumn);
1180
1181 int watermarkEndRow = row;
1182 if (classic)
1183 mainLayout->setRowMinimumHeight(row++, deltaVSpacing);
1184
1185 if (aero) {
1186 buttonLayout->setContentsMargins(9, 9, 9, 9);
1187 mainLayout->setContentsMargins(0, 11, 0, 0);
1188 }
1189
1190 int buttonStartColumn = info.extension ? 1 : 0;
1191 int buttonNumColumns = info.extension ? 1 : numColumns;
1192
1193 if (classic || modern) {
1194 if (!bottomRuler)
1195 bottomRuler = new QWizardRuler(antiFlickerWidget);
1196 mainLayout->addWidget(bottomRuler, row++, buttonStartColumn, 1, buttonNumColumns);
1197 }
1198
1199 if (classic)
1200 mainLayout->setRowMinimumHeight(row++, deltaVSpacing);
1201
1202 mainLayout->addLayout(buttonLayout, row++, buttonStartColumn, 1, buttonNumColumns);
1203
1204 if (info.watermark || info.sideWidget) {
1205 if (info.extension)
1206 watermarkEndRow = row;
1207 mainLayout->addWidget(watermarkLabel, watermarkStartRow, 0,
1208 watermarkEndRow - watermarkStartRow, 1);
1209 }
1210
1211 mainLayout->setColumnMinimumWidth(0, mac && !info.watermark ? 181 : 0);
1212 if (mac)
1213 mainLayout->setColumnMinimumWidth(2, 21);
1214
1215 if (headerWidget)
1216 headerWidget->setVisible(info.header);
1217 if (titleLabel)
1218 titleLabel->setVisible(info.title);
1219 if (subTitleLabel)
1220 subTitleLabel->setVisible(info.subTitle);
1221 if (bottomRuler)
1222 bottomRuler->setVisible(classic || modern);
1223 if (watermarkLabel)
1224 watermarkLabel->setVisible(info.watermark || info.sideWidget);
1225
1226 layoutInfo = info;
1227}
1228
1230{
1231 Q_Q(QWizard);
1232
1234
1236 if (layoutInfo != info)
1237 recreateLayout(info);
1238 QWizardPage *page = q->currentPage();
1239
1240 // If the page can expand vertically, let it stretch "infinitely" more
1241 // than the QSpacerItem at the bottom. Otherwise, let the QSpacerItem
1242 // stretch "infinitely" more than the page. Change the bottom item's
1243 // policy accordingly. The case that the page has no layout is basically
1244 // for Designer, only.
1245 if (page) {
1246 bool expandPage = !page->layout();
1247 if (!expandPage) {
1248 const QLayoutItem *pageItem = pageVBoxLayout->itemAt(pageVBoxLayout->indexOf(page));
1249 expandPage = pageItem->expandingDirections() & Qt::Vertical;
1250 }
1251 QSpacerItem *bottomSpacer = pageVBoxLayout->itemAt(pageVBoxLayout->count() - 1)->spacerItem();
1252 Q_ASSERT(bottomSpacer);
1253 bottomSpacer->changeSize(0, 0, QSizePolicy::Ignored, expandPage ? QSizePolicy::Ignored : QSizePolicy::MinimumExpanding);
1254 pageVBoxLayout->invalidate();
1255 }
1256
1257 if (info.header) {
1258 Q_ASSERT(page);
1259 headerWidget->setup(info, page->title(), page->subTitle(),
1260 page->pixmap(QWizard::LogoPixmap), page->pixmap(QWizard::BannerPixmap),
1261 titleFmt, subTitleFmt, opts);
1262 }
1263
1264 if (info.watermark || info.sideWidget) {
1265 QPixmap pix;
1266 if (info.watermark) {
1267 if (page)
1268 pix = page->pixmap(QWizard::WatermarkPixmap);
1269 else
1270 pix = q->pixmap(QWizard::WatermarkPixmap);
1271 }
1272 watermarkLabel->setPixmap(pix); // in case there is no watermark and we show the side widget we need to clear the watermark
1273 }
1274
1275 if (info.title) {
1276 Q_ASSERT(page);
1277 if (titleFmt)
1278 titleLabel->setTextFormat(titleFmt.value());
1279 titleLabel->setText(page->title());
1280 }
1281 if (info.subTitle) {
1282 Q_ASSERT(page);
1283 if (subTitleFmt)
1284 subTitleLabel->setTextFormat(subTitleFmt.value());
1285 subTitleLabel->setText(page->subTitle());
1286 }
1287
1290}
1291
1293 if (wizStyle == QWizard::MacStyle) {
1294 // This is required to ensure visual semitransparency when
1295 // switching from ModernStyle to MacStyle.
1296 // See TAG1 in recreateLayout
1297 // This additionally ensures that the colors are correct
1298 // when the theme is changed.
1299
1300 // we should base the new palette on the default one
1301 // so theme colors will be correct
1302 QPalette newPalette = QApplication::palette(pageFrame);
1303
1304 QColor windowColor = newPalette.brush(QPalette::Window).color();
1305 windowColor.setAlpha(153);
1306 newPalette.setBrush(QPalette::Window, windowColor);
1307
1308 QColor baseColor = newPalette.brush(QPalette::Base).color();
1309 baseColor.setAlpha(153);
1310 newPalette.setBrush(QPalette::Base, baseColor);
1311
1312 pageFrame->setPalette(newPalette);
1313 }
1314}
1315
1317{
1318 Q_Q(QWizard);
1319
1320 int extraHeight = 0;
1321#if QT_CONFIG(style_windowsvista)
1322 if (isVistaThemeEnabled())
1323 extraHeight = vistaHelper->titleBarSize() + vistaHelper->topOffset(q);
1324#endif
1325 QSize minimumSize = mainLayout->totalMinimumSize() + QSize(0, extraHeight);
1326 QSize maximumSize = mainLayout->totalMaximumSize();
1327 if (info.header && headerWidget->maximumWidth() != QWIDGETSIZE_MAX) {
1328 minimumSize.setWidth(headerWidget->maximumWidth());
1329 maximumSize.setWidth(headerWidget->maximumWidth());
1330 }
1331 if (info.watermark && !info.sideWidget) {
1332 minimumSize.setHeight(mainLayout->totalSizeHint().height());
1333 }
1334 if (q->minimumWidth() == minimumWidth) {
1335 minimumWidth = minimumSize.width();
1336 q->setMinimumWidth(minimumWidth);
1337 }
1338 if (q->minimumHeight() == minimumHeight) {
1339 minimumHeight = minimumSize.height();
1340 q->setMinimumHeight(minimumHeight);
1341 }
1342 if (q->maximumWidth() == maximumWidth) {
1343 maximumWidth = maximumSize.width();
1344 q->setMaximumWidth(maximumWidth);
1345 }
1346 if (q->maximumHeight() == maximumHeight) {
1347 maximumHeight = maximumSize.height();
1348 q->setMaximumHeight(maximumHeight);
1349 }
1350}
1351
1353{
1354 Q_Q(QWizard);
1355 if (q->currentPage()) {
1356 canContinue = (q->nextId() != -1);
1357 canFinish = q->currentPage()->isFinalPage();
1358 } else {
1359 canContinue = false;
1360 canFinish = false;
1361 }
1364}
1365
1366static QString object_name_for_button(QWizard::WizardButton which)
1367{
1368 switch (which) {
1369 case QWizard::CommitButton:
1370 return u"qt_wizard_commit"_s;
1371 case QWizard::FinishButton:
1372 return u"qt_wizard_finish"_s;
1373 case QWizard::CancelButton:
1374 return u"qt_wizard_cancel"_s;
1375 case QWizard::BackButton:
1376 case QWizard::NextButton:
1377 case QWizard::HelpButton:
1378 case QWizard::CustomButton1:
1379 case QWizard::CustomButton2:
1380 case QWizard::CustomButton3:
1381 // Make navigation buttons detectable as passive interactor in designer
1382 return "__qt__passive_wizardbutton"_L1 + QString::number(which);
1383 case QWizard::Stretch:
1384 case QWizard::NoButton:
1385 //case QWizard::NStandardButtons:
1386 //case QWizard::NButtons:
1387 ;
1388 }
1389 Q_UNREACHABLE_RETURN(QString());
1390}
1391
1392bool QWizardPrivate::ensureButton(QWizard::WizardButton which) const
1393{
1394 Q_Q(const QWizard);
1395 if (uint(which) >= QWizard::NButtons)
1396 return false;
1397
1398 if (!btns[which]) {
1399 QPushButton *pushButton = new QPushButton(antiFlickerWidget);
1400 QStyle *style = q->style();
1401 if (style != QApplication::style()) // Propagate style
1402 pushButton->setStyle(style);
1403 pushButton->setObjectName(object_name_for_button(which));
1404#ifdef Q_OS_MACOS
1405 pushButton->setAutoDefault(false);
1406#endif
1407 pushButton->hide();
1408#ifdef Q_CC_HPACC
1409 const_cast<QWizardPrivate *>(this)->btns[which] = pushButton;
1410#else
1411 btns[which] = pushButton;
1412#endif
1413 if (which < QWizard::NStandardButtons)
1414 pushButton->setText(buttonDefaultText(wizStyle, which, this));
1415
1416 connectButton(which);
1417 }
1418 return true;
1419}
1420
1421void QWizardPrivate::connectButton(QWizard::WizardButton which) const
1422{
1423 Q_Q(const QWizard);
1424 if (which < QWizard::NStandardButtons) {
1425 QObject::connect(btns[which], SIGNAL(clicked()), q, buttonSlots(which));
1426 } else {
1427 QObject::connect(btns[which], SIGNAL(clicked()), q, SLOT(_q_emitCustomButtonClicked()));
1428 }
1429}
1430
1432{
1433 Q_Q(QWizard);
1434 for (int i = 0; i < QWizard::NButtons; ++i) {
1435 if (btns[i]) {
1436 if (q->currentPage() && (q->currentPage()->d_func()->buttonCustomTexts.contains(i)))
1437 btns[i]->setText(q->currentPage()->d_func()->buttonCustomTexts.value(i));
1438 else if (buttonCustomTexts.contains(i))
1439 btns[i]->setText(buttonCustomTexts.value(i));
1440 else if (i < QWizard::NStandardButtons)
1441 btns[i]->setText(buttonDefaultText(wizStyle, i, this));
1442 }
1443 }
1444 // Vista: Add shortcut for 'next'. Note: native dialogs use ALT-Right
1445 // even in RTL mode, so do the same, even if it might be counter-intuitive.
1446 // The shortcut for 'back' is set in class QVistaBackButton.
1447#if QT_CONFIG(shortcut) && QT_CONFIG(style_windowsvista)
1448 if (btns[QWizard::NextButton] && isVistaThemeEnabled()) {
1449 if (vistaNextShortcut.isNull()) {
1450 vistaNextShortcut =
1451 new QShortcut(QKeySequence(Qt::ALT | Qt::Key_Right),
1452 btns[QWizard::NextButton], SLOT(animateClick()));
1453 }
1454 } else {
1455 delete vistaNextShortcut;
1456 }
1457#endif // shortcut && style_windowsvista
1458}
1459
1461{
1463 QVarLengthArray<QWizard::WizardButton, QWizard::NButtons> array{
1464 buttonsCustomLayout.cbegin(), buttonsCustomLayout.cend()};
1465 setButtonLayout(array.constData(), int(array.size()));
1466 } else {
1467 // Positions:
1468 // Help Stretch Custom1 Custom2 Custom3 Cancel Back Next Commit Finish Cancel Help
1469
1470 const int ArraySize = 12;
1471 QWizard::WizardButton array[ArraySize];
1472 memset(array, -1, sizeof(array));
1473 Q_ASSERT(array[0] == QWizard::NoButton);
1474
1475 if (opts & QWizard::HaveHelpButton) {
1476 int i = (opts & QWizard::HelpButtonOnRight) ? 11 : 0;
1477 array[i] = QWizard::HelpButton;
1478 }
1479 array[1] = QWizard::Stretch;
1480 if (opts & QWizard::HaveCustomButton1)
1481 array[2] = QWizard::CustomButton1;
1482 if (opts & QWizard::HaveCustomButton2)
1483 array[3] = QWizard::CustomButton2;
1484 if (opts & QWizard::HaveCustomButton3)
1485 array[4] = QWizard::CustomButton3;
1486
1487 if (!(opts & QWizard::NoCancelButton)) {
1488 int i = (opts & QWizard::CancelButtonOnLeft) ? 5 : 10;
1489 array[i] = QWizard::CancelButton;
1490 }
1491 array[6] = QWizard::BackButton;
1492 array[7] = QWizard::NextButton;
1493 array[8] = QWizard::CommitButton;
1494 array[9] = QWizard::FinishButton;
1495
1496 setButtonLayout(array, ArraySize);
1497 }
1498}
1499
1500void QWizardPrivate::setButtonLayout(const QWizard::WizardButton *array, int size)
1501{
1502 QWidget *prev = pageFrame;
1503
1504 for (int i = buttonLayout->count() - 1; i >= 0; --i) {
1505 QLayoutItem *item = buttonLayout->takeAt(i);
1506 if (QWidget *widget = item->widget())
1507 widget->hide();
1508 delete item;
1509 }
1510
1511 for (int i = 0; i < size; ++i) {
1512 QWizard::WizardButton which = array[i];
1513 if (which == QWizard::Stretch) {
1514 buttonLayout->addStretch(1);
1515 } else if (which != QWizard::NoButton) {
1516 ensureButton(which);
1517 buttonLayout->addWidget(btns[which]);
1518
1519 // Back, Next, Commit, and Finish are handled in _q_updateButtonStates()
1520 if (which != QWizard::BackButton && which != QWizard::NextButton
1521 && which != QWizard::CommitButton && which != QWizard::FinishButton)
1522 btns[which]->show();
1523
1524 if (prev)
1525 QWidget::setTabOrder(prev, btns[which]);
1526 prev = btns[which];
1527 }
1528 }
1529
1531}
1532
1533bool QWizardPrivate::buttonLayoutContains(QWizard::WizardButton which)
1534{
1535 return !buttonsHaveCustomLayout || buttonsCustomLayout.contains(which);
1536}
1537
1538void QWizardPrivate::updatePixmap(QWizard::WizardPixmap which)
1539{
1540 Q_Q(QWizard);
1541 if (which == QWizard::BackgroundPixmap) {
1542 if (wizStyle == QWizard::MacStyle) {
1543 q->update();
1544 q->updateGeometry();
1545 }
1546 } else {
1548 }
1549}
1550
1551#if QT_CONFIG(style_windowsvista)
1552bool QWizardPrivate::vistaDisabled() const
1553{
1554 Q_Q(const QWizard);
1555 const QVariant v = q->property("_q_wizard_vista_off");
1556 return v.isValid() && v.toBool();
1557}
1558
1559bool QWizardPrivate::handleAeroStyleChange()
1560{
1561 Q_Q(QWizard);
1562
1563 if (inHandleAeroStyleChange)
1564 return false; // prevent recursion
1565 // For top-level wizards, we need the platform window handle for the
1566 // DWM changes. Delay aero initialization to the show event handling if
1567 // it does not exist. If we are a child, skip DWM and just make room by
1568 // moving the antiFlickerWidget.
1569 const bool isWindow = q->isWindow();
1570 if (isWindow && (!q->windowHandle() || !q->windowHandle()->handle()))
1571 return false;
1572 inHandleAeroStyleChange = true;
1573
1574 vistaHelper->disconnectBackButton();
1575 q->removeEventFilter(vistaHelper);
1576
1577 bool vistaMargins = false;
1578
1579 if (isVistaThemeEnabled()) {
1580 const int topOffset = vistaHelper->topOffset(q);
1581 const int topPadding = vistaHelper->topPadding(q);
1582 if (isWindow) {
1583 vistaHelper->setDWMTitleBar(QVistaHelper::ExtendedTitleBar);
1584 q->installEventFilter(vistaHelper);
1585 }
1586 q->setMouseTracking(true);
1587 antiFlickerWidget->move(0, vistaHelper->titleBarSize() + topOffset);
1588 vistaHelper->backButton()->move(
1589 0, topOffset // ### should ideally work without the '+ 1'
1590 - qMin(topOffset, topPadding + 1));
1591 vistaMargins = true;
1592 vistaHelper->backButton()->show();
1593 if (isWindow)
1594 vistaHelper->setTitleBarIconAndCaptionVisible(false);
1595 QObject::connect(
1596 vistaHelper->backButton(), SIGNAL(clicked()), q, buttonSlots(QWizard::BackButton));
1597 vistaHelper->backButton()->show();
1598 } else {
1599 q->setMouseTracking(true); // ### original value possibly different
1600#ifndef QT_NO_CURSOR
1601 q->unsetCursor(); // ### ditto
1602#endif
1603 antiFlickerWidget->move(0, 0);
1604 vistaHelper->hideBackButton();
1605 if (isWindow)
1606 vistaHelper->setTitleBarIconAndCaptionVisible(true);
1607 }
1608
1609 _q_updateButtonStates();
1610
1611 vistaHelper->updateCustomMargins(vistaMargins);
1612
1613 inHandleAeroStyleChange = false;
1614 return true;
1615}
1616#endif
1617
1619{
1620#if QT_CONFIG(style_windowsvista)
1621 return wizStyle == QWizard::AeroStyle && !vistaDisabled();
1622#else
1623 return false;
1624#endif
1625}
1626
1628{
1629 Q_Q(QWizard);
1630 if (disableUpdatesCount++ == 0) {
1631 q->setUpdatesEnabled(false);
1632 antiFlickerWidget->hide();
1633 }
1634}
1635
1637{
1638 Q_Q(QWizard);
1639 if (--disableUpdatesCount == 0) {
1640 antiFlickerWidget->show();
1641 q->setUpdatesEnabled(true);
1642 }
1643}
1644
1646{
1647 Q_Q(QWizard);
1648 QObject *button = q->sender();
1649 for (int i = QWizard::NStandardButtons; i < QWizard::NButtons; ++i) {
1650 if (btns[i] == button) {
1651 emit q->customButtonClicked(QWizard::WizardButton(i));
1652 break;
1653 }
1654 }
1655}
1656
1658{
1659 Q_Q(QWizard);
1660
1662
1663 const QWizardPage *page = q->currentPage();
1664 bool complete = page && page->isComplete();
1665
1666 btn.back->setEnabled(history.size() > 1
1667 && !q->page(history.at(history.size() - 2))->isCommitPage()
1668 && (!canFinish || !(opts & QWizard::DisabledBackButtonOnLastPage)));
1669 btn.next->setEnabled(canContinue && complete);
1670 btn.commit->setEnabled(canContinue && complete);
1671 btn.finish->setEnabled(canFinish && complete);
1672
1673 const bool backButtonVisible = buttonLayoutContains(QWizard::BackButton)
1674 && (history.size() > 1 || !(opts & QWizard::NoBackButtonOnStartPage))
1675 && (canContinue || !(opts & QWizard::NoBackButtonOnLastPage));
1676 bool commitPage = page && page->isCommitPage();
1677 btn.back->setVisible(backButtonVisible);
1678 btn.next->setVisible(buttonLayoutContains(QWizard::NextButton) && !commitPage
1679 && (canContinue || (opts & QWizard::HaveNextButtonOnLastPage)));
1680 btn.commit->setVisible(buttonLayoutContains(QWizard::CommitButton) && commitPage
1681 && canContinue);
1682 btn.finish->setVisible(buttonLayoutContains(QWizard::FinishButton)
1683 && (canFinish || (opts & QWizard::HaveFinishButtonOnEarlyPages)));
1684
1685 if (!(opts & QWizard::NoCancelButton))
1686 btn.cancel->setVisible(buttonLayoutContains(QWizard::CancelButton)
1687 && (canContinue || !(opts & QWizard::NoCancelButtonOnLastPage)));
1688
1689 bool useDefault = !(opts & QWizard::NoDefaultButton);
1690 if (QPushButton *nextPush = qobject_cast<QPushButton *>(btn.next))
1691 nextPush->setDefault(canContinue && useDefault && !commitPage);
1692 if (QPushButton *commitPush = qobject_cast<QPushButton *>(btn.commit))
1693 commitPush->setDefault(canContinue && useDefault && commitPage);
1694 if (QPushButton *finishPush = qobject_cast<QPushButton *>(btn.finish))
1695 finishPush->setDefault(!canContinue && useDefault);
1696
1697#if QT_CONFIG(style_windowsvista)
1698 if (isVistaThemeEnabled()) {
1699 vistaHelper->backButton()->setEnabled(btn.back->isEnabled());
1700 vistaHelper->backButton()->setVisible(backButtonVisible);
1701 btn.back->setVisible(false);
1702 }
1703#endif
1704
1706}
1707
1709{
1710 int destroyed_index = -1;
1711 QList<QWizardField>::iterator it = fields.begin();
1712 while (it != fields.end()) {
1713 const QWizardField &field = *it;
1714 if (field.object == object) {
1715 destroyed_index = fieldIndexMap.value(field.name, -1);
1716 fieldIndexMap.remove(field.name);
1717 it = fields.erase(it);
1718 } else {
1719 ++it;
1720 }
1721 }
1722 if (destroyed_index != -1) {
1723 QMap<QString, int>::iterator it2 = fieldIndexMap.begin();
1724 while (it2 != fieldIndexMap.end()) {
1725 int index = it2.value();
1726 if (index > destroyed_index) {
1727 QString field_name = it2.key();
1728 fieldIndexMap.insert(field_name, index-1);
1729 }
1730 ++it2;
1731 }
1732 }
1733}
1734
1735void QWizardPrivate::setStyle(QStyle *style)
1736{
1737 for (int i = 0; i < QWizard::NButtons; i++)
1738 if (btns[i])
1739 btns[i]->setStyle(style);
1740 const PageMap::const_iterator pcend = pageMap.constEnd();
1741 for (PageMap::const_iterator it = pageMap.constBegin(); it != pcend; ++it)
1742 it.value()->setStyle(style);
1743}
1744
1745#ifdef Q_OS_MACOS
1746QPixmap QWizardPrivate::findDefaultBackgroundPixmap()
1747{
1748 auto *keyboardAssistantURL = [NSWorkspace.sharedWorkspace
1749 URLForApplicationWithBundleIdentifier:@"com.apple.KeyboardSetupAssistant"];
1750 auto *keyboardAssistantBundle = [NSBundle bundleWithURL:keyboardAssistantURL];
1751 auto *assistantBackground = [keyboardAssistantBundle imageForResource:@"Background"];
1752 auto size = QSizeF::fromCGSize(assistantBackground.size);
1753 static const QSizeF expectedSize(242, 414);
1754 if (size == expectedSize)
1755 return qt_mac_toQPixmap(assistantBackground, size);
1756
1757 return QPixmap();
1758}
1759#endif
1760
1761#if QT_CONFIG(style_windowsvista)
1762void QWizardAntiFlickerWidget::paintEvent(QPaintEvent *)
1763{
1764 if (wizardPrivate->isVistaThemeEnabled()) {
1765 int leftMargin, topMargin, rightMargin, bottomMargin;
1766 wizardPrivate->buttonLayout->getContentsMargins(
1767 &leftMargin, &topMargin, &rightMargin, &bottomMargin);
1768 const int buttonLayoutTop = wizardPrivate->buttonLayout->contentsRect().top() - topMargin;
1769 QPainter painter(this);
1770 const QBrush brush(QColor(240, 240, 240)); // ### hardcoded for now
1771 painter.fillRect(0, buttonLayoutTop, width(), height() - buttonLayoutTop, brush);
1772 painter.setPen(QPen(QBrush(QColor(223, 223, 223)), 0)); // ### hardcoded for now
1773 painter.drawLine(0, buttonLayoutTop, width(), buttonLayoutTop);
1774 }
1775}
1776#endif
1777
1778/*!
1779 \class QWizard
1780 \brief The QWizard class provides a framework for wizards.
1781
1782 \inmodule QtWidgets
1783
1784 A wizard (also called an assistant on \macos) is a special type
1785 of input dialog that consists of a sequence of pages. A wizard's
1786 purpose is to guide the user through a process step by step.
1787 Wizards are useful for complex or infrequent tasks that users may
1788 find difficult to learn.
1789
1790 QWizard inherits QDialog and represents a wizard. Each page is a
1791 QWizardPage (a QWidget subclass). To create your own wizards, you
1792 can use these classes directly, or you can subclass them for more
1793 control.
1794
1795 \section1 A Trivial Example
1796
1797 The following example illustrates how to create wizard pages and
1798 add them to a wizard. For more advanced examples, see the
1799 \l{dialogs/licensewizard}{License Wizard}.
1800
1801 \snippet dialogs/trivialwizard/trivialwizard.cpp 1
1802 \snippet dialogs/trivialwizard/trivialwizard.cpp 3
1803 \dots
1804 \snippet dialogs/trivialwizard/trivialwizard.cpp 4
1805 \codeline
1806 \snippet dialogs/trivialwizard/trivialwizard.cpp 5
1807 \snippet dialogs/trivialwizard/trivialwizard.cpp 7
1808 \dots
1809 \snippet dialogs/trivialwizard/trivialwizard.cpp 8
1810 \codeline
1811 \snippet dialogs/trivialwizard/trivialwizard.cpp 10
1812
1813 \section1 Wizard Look and Feel
1814
1815 QWizard supports four wizard looks:
1816
1817 \list
1818 \li ClassicStyle
1819 \li ModernStyle
1820 \li MacStyle
1821 \li AeroStyle
1822 \endlist
1823
1824 You can explicitly set the look to use using setWizardStyle()
1825 (e.g., if you want the same look on all platforms).
1826
1827 \table
1828 \header \li ClassicStyle
1829 \li ModernStyle
1830 \li MacStyle
1831 \li AeroStyle
1832 \row \li \inlineimage qtwizard-classic1.png {Wizard with ClassicStyle}
1833 \li \inlineimage qtwizard-modern1.png {Wizard with ModernStyle}
1834 \li \inlineimage qtwizard-mac1.png {Wizard with MacStyle}
1835 \li \inlineimage qtwizard-aero1.png {Wizard with AeroStyle}
1836 \row \li \inlineimage qtwizard-classic2.png {Wizard with ClassicStyle}
1837 \li \inlineimage qtwizard-modern2.png {Wizard with ModernStyle}
1838 \li \inlineimage qtwizard-mac2.png {Wizard with MacStyle}
1839 \li \inlineimage qtwizard-aero2.png {Wizard with AeroStyle}
1840 \endtable
1841
1842 Note: AeroStyle has effect only on a Windows Vista system with alpha compositing enabled.
1843 ModernStyle is used as a fallback when this condition is not met.
1844
1845 In addition to the wizard style, there are several options that
1846 control the look and feel of the wizard. These can be set using
1847 setOption() or setOptions(). For example, HaveHelpButton makes
1848 QWizard show a \uicontrol Help button along with the other wizard
1849 buttons.
1850
1851 You can even change the order of the wizard buttons to any
1852 arbitrary order using setButtonLayout(), and you can add up to
1853 three custom buttons (e.g., a \uicontrol Print button) to the button
1854 row. This is achieved by calling setButton() or setButtonText()
1855 with CustomButton1, CustomButton2, or CustomButton3 to set up the
1856 button, and by enabling the HaveCustomButton1, HaveCustomButton2,
1857 or HaveCustomButton3 options. Whenever the user clicks a custom
1858 button, customButtonClicked() is emitted. For example:
1859
1860 \snippet dialogs/licensewizard/licensewizard.cpp 29
1861
1862 \section1 Elements of a Wizard Page
1863
1864 Wizards consist of a sequence of \l{QWizardPage}s. At any time,
1865 only one page is shown. A page has the following attributes:
1866
1867 \list
1868 \li A \l{QWizardPage::}{title}.
1869 \li A \l{QWizardPage::}{subTitle}.
1870 \li A set of pixmaps, which may or may not be honored, depending
1871 on the wizard's style:
1872 \list
1873 \li WatermarkPixmap (used by ClassicStyle and ModernStyle)
1874 \li BannerPixmap (used by ModernStyle)
1875 \li LogoPixmap (used by ClassicStyle and ModernStyle)
1876 \li BackgroundPixmap (used by MacStyle)
1877 \endlist
1878 \endlist
1879
1880 The diagram belows shows how QWizard renders these attributes,
1881 assuming they are all present and ModernStyle is used:
1882
1883 \image qtwizard-nonmacpage.png {Attributes on a wizard page}
1884
1885 When a \l{QWizardPage::}{subTitle} is set, QWizard displays it
1886 in a header, in which case it also uses the BannerPixmap and the
1887 LogoPixmap to decorate the header. The WatermarkPixmap is
1888 displayed on the left side, below the header. At the bottom,
1889 there is a row of buttons allowing the user to navigate through
1890 the pages.
1891
1892 The page itself (the \l{QWizardPage} widget) occupies the area
1893 between the header, the watermark, and the button row. Typically,
1894 the page is a QWizardPage on which a QGridLayout is installed,
1895 with standard child widgets (\l{QLabel}s, \l{QLineEdit}s, etc.).
1896
1897 If the wizard's style is MacStyle, the page looks radically
1898 different:
1899
1900 \image qtwizard-macpage.png {Attributes on a wizard page using MacStyle}
1901
1902 The watermark, banner, and logo pixmaps are ignored by the
1903 MacStyle. If the BackgroundPixmap is set, it is used as the
1904 background for the wizard; otherwise, a default "assistant" image
1905 is used.
1906
1907 The title and subtitle are set by calling
1908 QWizardPage::setTitle() and QWizardPage::setSubTitle() on the
1909 individual pages. They may be plain text or HTML (see titleFormat
1910 and subTitleFormat). The pixmaps can be set globally for the
1911 entire wizard using setPixmap(), or on a per-page basis using
1912 QWizardPage::setPixmap().
1913
1914 \target field mechanism
1915 \section1 Registering and Using Fields
1916
1917 In many wizards, the contents of a page may affect the default
1918 values of the fields of a later page. To make it easy to
1919 communicate between pages, QWizard supports a "field" mechanism
1920 that allows you to register a field (e.g., a QLineEdit) on a page
1921 and to access its value from any page. It is also possible to
1922 specify mandatory fields (i.e., fields that must be filled before
1923 the user can advance to the next page).
1924
1925 To register a field, call QWizardPage::registerField() field.
1926 For example:
1927
1928 \snippet dialogs/licensewizard/licensewizard.cpp 21
1929
1930 The above code registers three fields, \c className, \c
1931 baseClass, and \c qobjectMacro, which are associated with three
1932 child widgets. The asterisk (\c *) next to \c className denotes a
1933 mandatory field.
1934
1935 \target initialize page
1936 The fields of any page are accessible from any other page. For
1937 example:
1938
1939 \snippet dialogs/licensewizard/licensewizard.cpp 27
1940
1941 Here, we call QWizardPage::field() to access the contents of the
1942 \c details.email field (which was defined in the \c DetailsPage)
1943 and use it to initialize the \c ConclusionPage. The field's
1944 contents is returned as a QVariant.
1945
1946 When we create a field using QWizardPage::registerField(), we
1947 pass a unique field name and a widget. We can also provide a Qt
1948 property name and a "changed" signal (a signal that is emitted
1949 when the property changes) as third and fourth arguments;
1950 however, this is not necessary for the most common Qt widgets,
1951 such as QLineEdit, QCheckBox, and QComboBox, because QWizard
1952 knows which properties to look for.
1953
1954 \target mandatory fields
1955
1956 If an asterisk (\c *) is appended to the name when the property
1957 is registered, the field is a \e{mandatory field}. When a page has
1958 mandatory fields, the \uicontrol Next and/or \uicontrol Finish buttons are
1959 enabled only when all mandatory fields are filled.
1960
1961 To consider a field "filled", QWizard simply checks that the
1962 field's current value doesn't equal the original value (the value
1963 it had when initializePage() was called). For QLineEdit and
1964 QAbstractSpinBox subclasses, QWizard also checks that
1965 \l{QLineEdit::hasAcceptableInput()}{hasAcceptableInput()} returns
1966 true, to honor any validator or mask.
1967
1968 QWizard's mandatory field mechanism is provided for convenience.
1969 A more powerful (but also more cumbersome) alternative is to
1970 reimplement QWizardPage::isComplete() and to emit the
1971 QWizardPage::completeChanged() signal whenever the page becomes
1972 complete or incomplete.
1973
1974 The enabled/disabled state of the \uicontrol Next and/or \uicontrol Finish
1975 buttons is one way to perform validation on the user input.
1976 Another way is to reimplement validateCurrentPage() (or
1977 QWizardPage::validatePage()) to perform some last-minute
1978 validation (and show an error message if the user has entered
1979 incomplete or invalid information). If the function returns \c true,
1980 the next page is shown (or the wizard finishes); otherwise, the
1981 current page stays up.
1982
1983 \section1 Creating Linear Wizards
1984
1985 Most wizards have a linear structure, with page 1 followed by
1986 page 2 and so on until the last page. The \l{dialogs/trivialwizard}
1987 {Trivial Wizard} example is such a wizard. With QWizard, linear wizards
1988 are created by instantiating the \l{QWizardPage}s and inserting
1989 them using addPage(). By default, the pages are shown in the
1990 order in which they were added. For example:
1991
1992 \snippet dialogs/trivialwizard/trivialwizard.cpp linearAddPage
1993
1994 When a page is about to be shown, QWizard calls initializePage()
1995 (which in turn calls QWizardPage::initializePage()) to fill the
1996 page with default values. By default, this function does nothing,
1997 but it can be reimplemented to initialize the page's contents
1998 based on other pages' fields (see the \l{initialize page}{example
1999 above}).
2000
2001 If the user presses \uicontrol Back, cleanupPage() is called (which in
2002 turn calls QWizardPage::cleanupPage()). The default
2003 implementation resets the page's fields to their original values
2004 (the values they had before initializePage() was called). If you
2005 want the \uicontrol Back button to be non-destructive and keep the
2006 values entered by the user, simply enable the IndependentPages
2007 option.
2008
2009 \section1 Creating Non-Linear Wizards
2010
2011 Some wizards are more complex in that they allow different
2012 traversal paths based on the information provided by the user.
2013 The \l{dialogs/licensewizard}{License Wizard} example illustrates this.
2014 It provides several wizard pages; depending on which options are
2015 selected, the user can reach different pages.
2016
2017 \image licensewizard-flow.png {Complex wizard page flow chart}
2018
2019 In complex wizards, pages are identified by IDs. These IDs are
2020 typically defined using an enum. For example:
2021
2022 \snippet dialogs/licensewizard/licensewizard.h 0
2023 \dots
2024 \snippet dialogs/licensewizard/licensewizard.h 2
2025 \dots
2026 \snippet dialogs/licensewizard/licensewizard.h 3
2027
2028 The pages are inserted using setPage(), which takes an ID and an
2029 instance of QWizardPage (or of a subclass):
2030
2031 \snippet dialogs/licensewizard/licensewizard.cpp 1
2032 \dots
2033 \snippet dialogs/licensewizard/licensewizard.cpp 8
2034
2035 By default, the pages are shown in increasing ID order. To
2036 provide a dynamic order that depends on the options chosen by the
2037 user, we must reimplement QWizardPage::nextId(). For example:
2038
2039 \snippet dialogs/licensewizard/licensewizard.cpp 18
2040 \codeline
2041 \snippet dialogs/licensewizard/licensewizard.cpp 23
2042 \codeline
2043 \snippet dialogs/licensewizard/licensewizard.cpp 24
2044 \codeline
2045 \snippet dialogs/licensewizard/licensewizard.cpp 25
2046 \codeline
2047 \snippet dialogs/licensewizard/licensewizard.cpp 26
2048
2049 It would also be possible to put all the logic in one place, in a
2050 QWizard::nextId() reimplementation. For example:
2051
2052 \snippet code/src_gui_dialogs_qwizard.cpp 0
2053
2054 To start at another page than the page with the lowest ID, call
2055 setStartId().
2056
2057 To test whether a page has been visited or not, call
2058 hasVisitedPage(). For example:
2059
2060 \snippet dialogs/licensewizard/licensewizard.cpp 27
2061
2062 \sa QWizardPage, {Trivial Wizard Example}, {License Wizard Example}
2063*/
2064
2065/*!
2066 \enum QWizard::WizardButton
2067
2068 This enum specifies the buttons in a wizard.
2069
2070 \value BackButton The \uicontrol Back button (\uicontrol {Go Back} on \macos)
2071 \value NextButton The \uicontrol Next button (\uicontrol Continue on \macos)
2072 \value CommitButton The \uicontrol Commit button
2073 \value FinishButton The \uicontrol Finish button (\uicontrol Done on \macos)
2074 \value CancelButton The \uicontrol Cancel button (see also NoCancelButton)
2075 \value HelpButton The \uicontrol Help button (see also HaveHelpButton)
2076 \value CustomButton1 The first user-defined button (see also HaveCustomButton1)
2077 \value CustomButton2 The second user-defined button (see also HaveCustomButton2)
2078 \value CustomButton3 The third user-defined button (see also HaveCustomButton3)
2079
2080 The following value is only useful when calling setButtonLayout():
2081
2082 \value Stretch A horizontal stretch in the button layout
2083
2084 \omitvalue NoButton
2085 \omitvalue NStandardButtons
2086 \omitvalue NButtons
2087
2088 \sa setButton(), setButtonText(), setButtonLayout(), customButtonClicked()
2089*/
2090
2091/*!
2092 \enum QWizard::WizardPixmap
2093
2094 This enum specifies the pixmaps that can be associated with a page.
2095
2096 \value WatermarkPixmap The tall pixmap on the left side of a ClassicStyle or ModernStyle page
2097 \value LogoPixmap The small pixmap on the right side of a ClassicStyle or ModernStyle page header
2098 \value BannerPixmap The pixmap that occupies the background of a ModernStyle page header
2099 \value BackgroundPixmap The pixmap that occupies the background of a MacStyle wizard
2100
2101 \omitvalue NPixmaps
2102
2103 \sa setPixmap(), QWizardPage::setPixmap(), {Elements of a Wizard Page}
2104*/
2105
2106/*!
2107 \enum QWizard::WizardStyle
2108
2109 This enum specifies the different looks supported by QWizard.
2110
2111 \value ClassicStyle Classic Windows look
2112 \value ModernStyle Modern Windows look
2113 \value MacStyle \macos look
2114 \value AeroStyle Windows Aero look
2115
2116 \omitvalue NStyles
2117
2118 \sa setWizardStyle(), WizardOption, {Wizard Look and Feel}
2119*/
2120
2121/*!
2122 \enum QWizard::WizardOption
2123
2124 This enum specifies various options that affect the look and feel
2125 of a wizard.
2126
2127 \value IndependentPages The pages are independent of each other
2128 (i.e., they don't derive values from each
2129 other).
2130 \value IgnoreSubTitles Don't show any subtitles, even if they are set.
2131 \value ExtendedWatermarkPixmap Extend any WatermarkPixmap all the
2132 way down to the window's edge.
2133 \value NoDefaultButton Don't make the \uicontrol Next or \uicontrol Finish button the
2134 dialog's \l{QPushButton::setDefault()}{default button}.
2135 \value NoBackButtonOnStartPage Don't show the \uicontrol Back button on the start page.
2136 \value NoBackButtonOnLastPage Don't show the \uicontrol Back button on the last page.
2137 \value DisabledBackButtonOnLastPage Disable the \uicontrol Back button on the last page.
2138 \value HaveNextButtonOnLastPage Show the (disabled) \uicontrol Next button on the last page.
2139 \value HaveFinishButtonOnEarlyPages Show the (disabled) \uicontrol Finish button on non-final pages.
2140 \value NoCancelButton Don't show the \uicontrol Cancel button.
2141 \value CancelButtonOnLeft Put the \uicontrol Cancel button on the left of \uicontrol Back (rather than on
2142 the right of \uicontrol Finish or \uicontrol Next).
2143 \value HaveHelpButton Show the \uicontrol Help button.
2144 \value HelpButtonOnRight Put the \uicontrol Help button on the far right of the button layout
2145 (rather than on the far left).
2146 \value HaveCustomButton1 Show the first user-defined button (CustomButton1).
2147 \value HaveCustomButton2 Show the second user-defined button (CustomButton2).
2148 \value HaveCustomButton3 Show the third user-defined button (CustomButton3).
2149 \value NoCancelButtonOnLastPage Don't show the \uicontrol Cancel button on the last page.
2150 \value StretchBanner If there is a \l{QWizard::WizardPixmap}{banner}, stretch it across
2151 the entire width of the wizard.
2152
2153 \sa setOptions(), setOption(), testOption()
2154*/
2155
2156/*!
2157 Constructs a wizard with the given \a parent and window \a flags.
2158
2159 \sa parent(), windowFlags()
2160*/
2161QWizard::QWizard(QWidget *parent, Qt::WindowFlags flags)
2162 : QDialog(*new QWizardPrivate, parent, flags)
2163{
2164 Q_D(QWizard);
2165 d->init();
2166}
2167
2168/*!
2169 Destroys the wizard and its pages, releasing any allocated resources.
2170*/
2171QWizard::~QWizard()
2172{
2173 Q_D(QWizard);
2174 delete d->buttonLayout;
2175}
2176
2177/*!
2178 Adds the given \a page to the wizard, and returns the page's ID.
2179
2180 The ID is guaranteed to be larger than any other ID in the
2181 QWizard so far.
2182
2183 \sa setPage(), page(), pageAdded()
2184*/
2185int QWizard::addPage(QWizardPage *page)
2186{
2187 Q_D(QWizard);
2188 int theid = 0;
2189 if (!d->pageMap.isEmpty())
2190 theid = d->pageMap.lastKey() + 1;
2191 setPage(theid, page);
2192 return theid;
2193}
2194
2195/*!
2196 \fn void QWizard::setPage(int id, QWizardPage *page)
2197
2198 Adds the given \a page to the wizard with the given \a id.
2199
2200 \note Adding a page may influence the value of the startId property
2201 in case it was not set explicitly.
2202
2203 \sa addPage(), page(), pageAdded()
2204*/
2205void QWizard::setPage(int theid, QWizardPage *page)
2206{
2207 Q_D(QWizard);
2208
2209 if (Q_UNLIKELY(!page)) {
2210 qWarning("QWizard::setPage: Cannot insert null page");
2211 return;
2212 }
2213
2214 if (Q_UNLIKELY(theid == -1)) {
2215 qWarning("QWizard::setPage: Cannot insert page with ID -1");
2216 return;
2217 }
2218
2219 if (Q_UNLIKELY(d->pageMap.contains(theid))) {
2220 qWarning("QWizard::setPage: Page with duplicate ID %d ignored", theid);
2221 return;
2222 }
2223
2224 page->setParent(d->pageFrame);
2225
2226 QList<QWizardField> &pendingFields = page->d_func()->pendingFields;
2227 for (const auto &field : std::as_const(pendingFields))
2228 d->addField(field);
2229 pendingFields.clear();
2230
2231 connect(page, SIGNAL(completeChanged()), this, SLOT(_q_updateButtonStates()));
2232
2233 d->pageMap.insert(theid, page);
2234 page->d_func()->wizard = this;
2235
2236 int n = d->pageVBoxLayout->count();
2237
2238 // disable layout to prevent layout updates while adding
2239 bool pageVBoxLayoutEnabled = d->pageVBoxLayout->isEnabled();
2240 d->pageVBoxLayout->setEnabled(false);
2241
2242 d->pageVBoxLayout->insertWidget(n - 1, page);
2243
2244 // hide new page and reset layout to old status
2245 page->hide();
2246 d->pageVBoxLayout->setEnabled(pageVBoxLayoutEnabled);
2247
2248 if (!d->startSetByUser && d->pageMap.constBegin().key() == theid)
2249 d->start = theid;
2250 emit pageAdded(theid);
2251}
2252
2253/*!
2254 Removes the page with the given \a id. cleanupPage() will be called if necessary.
2255
2256 \note Removing a page may influence the value of the startId property.
2257
2258 \sa addPage(), setPage(), pageRemoved(), startId()
2259*/
2260void QWizard::removePage(int id)
2261{
2262 Q_D(QWizard);
2263
2264 QWizardPage *removedPage = nullptr;
2265
2266 // update startItem accordingly
2267 if (d->pageMap.size() > 0) { // only if we have any pages
2268 if (d->start == id) {
2269 const int firstId = d->pageMap.constBegin().key();
2270 if (firstId == id) {
2271 if (d->pageMap.size() > 1)
2272 d->start = (++d->pageMap.constBegin()).key(); // secondId
2273 else
2274 d->start = -1; // removing the last page
2275 } else { // startSetByUser has to be "true" here
2276 d->start = firstId;
2277 }
2278 d->startSetByUser = false;
2279 }
2280 }
2281
2282 if (d->pageMap.contains(id))
2283 emit pageRemoved(id);
2284
2285 if (!d->history.contains(id)) {
2286 // Case 1: removing a page not in the history
2287 removedPage = d->pageMap.take(id);
2288 d->updateCurrentPage();
2289 } else if (id != d->current) {
2290 // Case 2: removing a page in the history before the current page
2291 removedPage = d->pageMap.take(id);
2292 d->history.removeOne(id);
2293 d->_q_updateButtonStates();
2294 } else if (d->history.size() == 1) {
2295 // Case 3: removing the current page which is the first (and only) one in the history
2296 d->reset();
2297 removedPage = d->pageMap.take(id);
2298 if (d->pageMap.isEmpty())
2299 d->updateCurrentPage();
2300 else
2301 restart();
2302 } else {
2303 // Case 4: removing the current page which is not the first one in the history
2304 back();
2305 removedPage = d->pageMap.take(id);
2306 d->updateCurrentPage();
2307 }
2308
2309 if (removedPage) {
2310 if (removedPage->d_func()->initialized) {
2311 cleanupPage(id);
2312 removedPage->d_func()->initialized = false;
2313 }
2314
2315 d->pageVBoxLayout->removeWidget(removedPage);
2316
2317 for (int i = d->fields.size() - 1; i >= 0; --i) {
2318 if (d->fields.at(i).page == removedPage) {
2319 removedPage->d_func()->pendingFields += d->fields.at(i);
2320 d->removeFieldAt(i);
2321 }
2322 }
2323 }
2324}
2325
2326/*!
2327 \fn QWizardPage *QWizard::page(int id) const
2328
2329 Returns the page with the given \a id, or \nullptr if there is no
2330 such page.
2331
2332 \sa addPage(), setPage()
2333*/
2334QWizardPage *QWizard::page(int theid) const
2335{
2336 Q_D(const QWizard);
2337 return d->pageMap.value(theid);
2338}
2339
2340/*!
2341 \fn bool QWizard::hasVisitedPage(int id) const
2342
2343 Returns \c true if the page history contains page \a id; otherwise,
2344 returns \c false.
2345
2346 Pressing \uicontrol Back marks the current page as "unvisited" again.
2347
2348 \sa visitedIds()
2349*/
2350bool QWizard::hasVisitedPage(int theid) const
2351{
2352 Q_D(const QWizard);
2353 return d->history.contains(theid);
2354}
2355
2356/*!
2357 \since 5.15
2358
2359 Returns the list of IDs of visited pages, in the order in which the pages
2360 were visited.
2361
2362 \sa hasVisitedPage()
2363*/
2364QList<int> QWizard::visitedIds() const
2365{
2366 Q_D(const QWizard);
2367 return d->history;
2368}
2369
2370/*!
2371 Returns the list of page IDs.
2372*/
2373QList<int> QWizard::pageIds() const
2374{
2375 Q_D(const QWizard);
2376 return d->pageMap.keys();
2377}
2378
2379/*!
2380 \property QWizard::startId
2381 \brief the ID of the first page
2382
2383 If this property isn't explicitly set, this property defaults to
2384 the lowest page ID in this wizard, or -1 if no page has been
2385 inserted yet.
2386
2387 \sa restart(), nextId()
2388*/
2389void QWizard::setStartId(int theid)
2390{
2391 Q_D(QWizard);
2392 int newStart = theid;
2393 if (theid == -1)
2394 newStart = d->pageMap.size() ? d->pageMap.constBegin().key() : -1;
2395
2396 if (d->start == newStart) {
2397 d->startSetByUser = theid != -1;
2398 return;
2399 }
2400
2401 if (Q_UNLIKELY(!d->pageMap.contains(newStart))) {
2402 qWarning("QWizard::setStartId: Invalid page ID %d", newStart);
2403 return;
2404 }
2405 d->start = newStart;
2406 d->startSetByUser = theid != -1;
2407}
2408
2409int QWizard::startId() const
2410{
2411 Q_D(const QWizard);
2412 return d->start;
2413}
2414
2415/*!
2416 Returns a pointer to the current page, or \nullptr if there is no
2417 current page (e.g., before the wizard is shown).
2418
2419 This is equivalent to calling page(currentId()).
2420
2421 \sa page(), currentId(), restart()
2422*/
2423QWizardPage *QWizard::currentPage() const
2424{
2425 Q_D(const QWizard);
2426 return page(d->current);
2427}
2428
2429/*!
2430 \property QWizard::currentId
2431 \brief the ID of the current page
2432
2433 By default, this property has a value of -1, indicating that no page is
2434 currently shown.
2435
2436 \sa currentPage()
2437*/
2438int QWizard::currentId() const
2439{
2440 Q_D(const QWizard);
2441 return d->current;
2442}
2443
2444/*!
2445 Sets the value of the field called \a name to \a value.
2446
2447 This function can be used to set fields on any page of the wizard.
2448
2449 \sa QWizardPage::registerField(), QWizardPage::setField(), field()
2450*/
2451void QWizard::setField(const QString &name, const QVariant &value)
2452{
2453 Q_D(QWizard);
2454
2455 int index = d->fieldIndexMap.value(name, -1);
2456 if (Q_UNLIKELY(index == -1)) {
2457 qWarning("QWizard::setField: No such field '%ls'", qUtf16Printable(name));
2458 return;
2459 }
2460
2461 const QWizardField &field = d->fields.at(index);
2462 if (Q_UNLIKELY(!field.object->setProperty(field.property, value)))
2463 qWarning("QWizard::setField: Couldn't write to property '%s'",
2464 field.property.constData());
2465}
2466
2467/*!
2468 Returns the value of the field called \a name.
2469
2470 This function can be used to access fields on any page of the wizard.
2471
2472 \sa QWizardPage::registerField(), QWizardPage::field(), setField()
2473*/
2474QVariant QWizard::field(const QString &name) const
2475{
2476 Q_D(const QWizard);
2477
2478 int index = d->fieldIndexMap.value(name, -1);
2479 if (Q_UNLIKELY(index == -1)) {
2480 qWarning("QWizard::field: No such field '%ls'", qUtf16Printable(name));
2481 return QVariant();
2482 }
2483
2484 const QWizardField &field = d->fields.at(index);
2485 return field.object->property(field.property);
2486}
2487
2488/*!
2489 \property QWizard::wizardStyle
2490 \brief the look and feel of the wizard
2491
2492 By default, QWizard uses the AeroStyle on a Windows Vista system with alpha compositing
2493 enabled, regardless of the current widget style. If this is not the case, the default
2494 wizard style depends on the current widget style as follows: MacStyle is the default if
2495 the current widget style is QMacStyle, ModernStyle is the default if the current widget
2496 style is QWindowsStyle, and ClassicStyle is the default in all other cases.
2497
2498 \sa {Wizard Look and Feel}, options
2499*/
2500void QWizard::setWizardStyle(WizardStyle style)
2501{
2502 Q_D(QWizard);
2503
2504 const bool styleChange = style != d->wizStyle;
2505
2506#if QT_CONFIG(style_windowsvista)
2507 const bool aeroStyleChange =
2508 d->vistaInitPending || d->vistaStateChanged || (styleChange && (style == AeroStyle || d->wizStyle == AeroStyle));
2509 d->vistaStateChanged = false;
2510 d->vistaInitPending = false;
2511#endif
2512
2513 if (styleChange
2514#if QT_CONFIG(style_windowsvista)
2515 || aeroStyleChange
2516#endif
2517 ) {
2518 d->disableUpdates();
2519 d->wizStyle = style;
2520 d->updateButtonTexts();
2521#if QT_CONFIG(style_windowsvista)
2522 if (aeroStyleChange) {
2523 //Send a resizeevent since the antiflicker widget probably needs a new size
2524 //because of the backbutton in the window title
2525 QResizeEvent ev(geometry().size(), geometry().size());
2526 QCoreApplication::sendEvent(this, &ev);
2527 }
2528#endif
2529 d->updateLayout();
2530 updateGeometry();
2531 d->enableUpdates();
2532#if QT_CONFIG(style_windowsvista)
2533 // Delay initialization when activating Aero style fails due to missing native window.
2534 if (aeroStyleChange && !d->handleAeroStyleChange() && d->wizStyle == AeroStyle)
2535 d->vistaInitPending = true;
2536#endif
2537 }
2538}
2539
2540QWizard::WizardStyle QWizard::wizardStyle() const
2541{
2542 Q_D(const QWizard);
2543 return d->wizStyle;
2544}
2545
2546/*!
2547 Sets the given \a option to be enabled if \a on is true;
2548 otherwise, clears the given \a option.
2549
2550 \sa options, testOption(), setWizardStyle()
2551*/
2552void QWizard::setOption(WizardOption option, bool on)
2553{
2554 Q_D(QWizard);
2555 if (!(d->opts & option) != !on)
2556 setOptions(d->opts ^ option);
2557}
2558
2559/*!
2560 Returns \c true if the given \a option is enabled; otherwise, returns
2561 false.
2562
2563 \sa options, setOption(), setWizardStyle()
2564*/
2565bool QWizard::testOption(WizardOption option) const
2566{
2567 Q_D(const QWizard);
2568 return (d->opts & option) != 0;
2569}
2570
2571/*!
2572 \property QWizard::options
2573 \brief the various options that affect the look and feel of the wizard
2574
2575 By default, the following options are set (depending on the platform):
2576
2577 \list
2578 \li Windows: HelpButtonOnRight.
2579 \li \macos: NoDefaultButton and NoCancelButton.
2580 \li X11 and QWS (Qt for Embedded Linux): none.
2581 \endlist
2582
2583 \sa wizardStyle
2584*/
2585void QWizard::setOptions(WizardOptions options)
2586{
2587 Q_D(QWizard);
2588
2589 WizardOptions changed = (options ^ d->opts);
2590 if (!changed)
2591 return;
2592
2593 d->disableUpdates();
2594
2595 d->opts = options;
2596 if ((changed & IndependentPages) && !(d->opts & IndependentPages))
2597 d->cleanupPagesNotInHistory();
2598
2599 if (changed & (NoDefaultButton | HaveHelpButton | HelpButtonOnRight | NoCancelButton
2600 | CancelButtonOnLeft | HaveCustomButton1 | HaveCustomButton2
2601 | HaveCustomButton3)) {
2602 d->updateButtonLayout();
2603 } else if (changed & (NoBackButtonOnStartPage | NoBackButtonOnLastPage
2604 | HaveNextButtonOnLastPage | HaveFinishButtonOnEarlyPages
2605 | DisabledBackButtonOnLastPage | NoCancelButtonOnLastPage)) {
2606 d->_q_updateButtonStates();
2607 }
2608
2609 d->enableUpdates();
2610 d->updateLayout();
2611}
2612
2613QWizard::WizardOptions QWizard::options() const
2614{
2615 Q_D(const QWizard);
2616 return d->opts;
2617}
2618
2619/*!
2620 Sets the text on button \a which to be \a text.
2621
2622 By default, the text on buttons depends on the wizardStyle. For
2623 example, on \macos, the \uicontrol Next button is called \uicontrol
2624 Continue.
2625
2626 To add extra buttons to the wizard (e.g., a \uicontrol Print button),
2627 one way is to call setButtonText() with CustomButton1,
2628 CustomButton2, or CustomButton3 to set their text, and make the
2629 buttons visible using the HaveCustomButton1, HaveCustomButton2,
2630 and/or HaveCustomButton3 options.
2631
2632 Button texts may also be set on a per-page basis using QWizardPage::setButtonText().
2633
2634 \sa setButton(), button(), setButtonLayout(), setOptions(), QWizardPage::setButtonText()
2635*/
2636void QWizard::setButtonText(WizardButton which, const QString &text)
2637{
2638 Q_D(QWizard);
2639
2640 if (!d->ensureButton(which))
2641 return;
2642
2643 d->buttonCustomTexts.insert(which, text);
2644
2645 if (!currentPage() || !currentPage()->d_func()->buttonCustomTexts.contains(which))
2646 d->btns[which]->setText(text);
2647}
2648
2649/*!
2650 Returns the text on button \a which.
2651
2652 If a text has ben set using setButtonText(), this text is returned.
2653
2654 By default, the text on buttons depends on the wizardStyle. For
2655 example, on \macos, the \uicontrol Next button is called \uicontrol
2656 Continue.
2657
2658 \sa button(), setButton(), setButtonText(), QWizardPage::buttonText(),
2659 QWizardPage::setButtonText()
2660*/
2661QString QWizard::buttonText(WizardButton which) const
2662{
2663 Q_D(const QWizard);
2664
2665 if (!d->ensureButton(which))
2666 return QString();
2667
2668 if (d->buttonCustomTexts.contains(which))
2669 return d->buttonCustomTexts.value(which);
2670
2671 const QString defText = buttonDefaultText(d->wizStyle, which, d);
2672 if (!defText.isNull())
2673 return defText;
2674
2675 return d->btns[which]->text();
2676}
2677
2678/*!
2679 Sets the order in which buttons are displayed to \a layout, where
2680 \a layout is a list of \l{WizardButton}s.
2681
2682 The default layout depends on the options (e.g., whether
2683 HelpButtonOnRight) that are set. You can call this function if
2684 you need more control over the buttons' layout than what \l
2685 options already provides.
2686
2687 You can specify horizontal stretches in the layout using \l
2688 Stretch.
2689
2690 Example:
2691
2692 \snippet code/src_gui_dialogs_qwizard.cpp 1
2693
2694 \sa setButton(), setButtonText(), setOptions()
2695*/
2696void QWizard::setButtonLayout(const QList<WizardButton> &layout)
2697{
2698 Q_D(QWizard);
2699
2700 for (int i = 0; i < layout.size(); ++i) {
2701 WizardButton button1 = layout.at(i);
2702
2703 if (button1 == NoButton || button1 == Stretch)
2704 continue;
2705 if (!d->ensureButton(button1))
2706 return;
2707
2708 // O(n^2), but n is very small
2709 for (int j = 0; j < i; ++j) {
2710 WizardButton button2 = layout.at(j);
2711 if (Q_UNLIKELY(button2 == button1)) {
2712 qWarning("QWizard::setButtonLayout: Duplicate button in layout");
2713 return;
2714 }
2715 }
2716 }
2717
2718 d->buttonsHaveCustomLayout = true;
2719 d->buttonsCustomLayout = layout;
2720 d->updateButtonLayout();
2721}
2722
2723/*!
2724 Sets the button corresponding to role \a which to \a button.
2725
2726 To add extra buttons to the wizard (e.g., a \uicontrol Print button),
2727 one way is to call setButton() with CustomButton1 to
2728 CustomButton3, and make the buttons visible using the
2729 HaveCustomButton1 to HaveCustomButton3 options.
2730
2731 \sa setButtonText(), setButtonLayout(), options
2732*/
2733void QWizard::setButton(WizardButton which, QAbstractButton *button)
2734{
2735 Q_D(QWizard);
2736
2737 if (uint(which) >= NButtons || d->btns[which] == button)
2738 return;
2739
2740 if (QAbstractButton *oldButton = d->btns[which]) {
2741 d->buttonLayout->removeWidget(oldButton);
2742 delete oldButton;
2743 }
2744
2745 d->btns[which] = button;
2746 if (button) {
2747 button->setParent(d->antiFlickerWidget);
2748 d->buttonCustomTexts.insert(which, button->text());
2749 d->connectButton(which);
2750 } else {
2751 d->buttonCustomTexts.remove(which); // ### what about page-specific texts set for 'which'
2752 d->ensureButton(which); // (QWizardPage::setButtonText())? Clear them as well?
2753 }
2754
2755 d->updateButtonLayout();
2756}
2757
2758/*!
2759 Returns the button corresponding to role \a which.
2760
2761 \sa setButton(), setButtonText()
2762*/
2763QAbstractButton *QWizard::button(WizardButton which) const
2764{
2765 Q_D(const QWizard);
2766#if QT_CONFIG(style_windowsvista)
2767 if (d->wizStyle == AeroStyle && which == BackButton)
2768 return d->vistaHelper->backButton();
2769#endif
2770 if (!d->ensureButton(which))
2771 return nullptr;
2772 return d->btns[which];
2773}
2774
2775/*!
2776 \property QWizard::titleFormat
2777 \brief the text format used by page titles
2778
2779 The default format is Qt::AutoText.
2780
2781 \sa QWizardPage::title, subTitleFormat
2782*/
2783void QWizard::setTitleFormat(Qt::TextFormat format)
2784{
2785 Q_D(QWizard);
2786 d->titleFmt = format;
2787 d->updateLayout();
2788}
2789
2790Qt::TextFormat QWizard::titleFormat() const
2791{
2792 Q_D(const QWizard);
2793 return d->titleFmt.value_or(Qt::AutoText);
2794}
2795
2796/*!
2797 \property QWizard::subTitleFormat
2798 \brief the text format used by page subtitles
2799
2800 The default format is Qt::AutoText.
2801
2802 \sa QWizardPage::title, titleFormat
2803*/
2804void QWizard::setSubTitleFormat(Qt::TextFormat format)
2805{
2806 Q_D(QWizard);
2807 d->subTitleFmt = format;
2808 d->updateLayout();
2809}
2810
2811Qt::TextFormat QWizard::subTitleFormat() const
2812{
2813 Q_D(const QWizard);
2814 return d->subTitleFmt.value_or(Qt::AutoText);
2815}
2816
2817/*!
2818 Sets the pixmap for role \a which to \a pixmap.
2819
2820 The pixmaps are used by QWizard when displaying a page. Which
2821 pixmaps are actually used depend on the \l{Wizard Look and
2822 Feel}{wizard style}.
2823
2824 Pixmaps can also be set for a specific page using
2825 QWizardPage::setPixmap().
2826
2827 \sa QWizardPage::setPixmap(), {Elements of a Wizard Page}
2828*/
2829void QWizard::setPixmap(WizardPixmap which, const QPixmap &pixmap)
2830{
2831 Q_D(QWizard);
2832 Q_ASSERT(uint(which) < NPixmaps);
2833 d->defaultPixmaps[which] = pixmap;
2834 d->updatePixmap(which);
2835}
2836
2837/*!
2838 Returns the pixmap set for role \a which.
2839
2840 By default, the only pixmap that is set is the BackgroundPixmap on
2841 \macos.
2842
2843 \sa QWizardPage::pixmap(), {Elements of a Wizard Page}
2844*/
2845QPixmap QWizard::pixmap(WizardPixmap which) const
2846{
2847 Q_D(const QWizard);
2848 Q_ASSERT(uint(which) < NPixmaps);
2849#ifdef Q_OS_MACOS
2850 if (which == BackgroundPixmap && d->defaultPixmaps[BackgroundPixmap].isNull())
2851 d->defaultPixmaps[BackgroundPixmap] = d->findDefaultBackgroundPixmap();
2852#endif
2853 return d->defaultPixmaps[which];
2854}
2855
2856/*!
2857 Sets the default property for \a className to be \a property,
2858 and the associated change signal to be \a changedSignal.
2859
2860 The default property is used when an instance of \a className (or
2861 of one of its subclasses) is passed to
2862 QWizardPage::registerField() and no property is specified.
2863
2864 QWizard knows the most common Qt widgets. For these (or their
2865 subclasses), you don't need to specify a \a property or a \a
2866 changedSignal. The table below lists these widgets:
2867
2868 \table
2869 \header \li Widget \li Property \li Change Notification Signal
2870 \row \li QAbstractButton \li bool \l{QAbstractButton::}{checked} \li \l{QAbstractButton::}{toggled()}
2871 \row \li QAbstractSlider \li int \l{QAbstractSlider::}{value} \li \l{QAbstractSlider::}{valueChanged()}
2872 \row \li QComboBox \li int \l{QComboBox::}{currentIndex} \li \l{QComboBox::}{currentIndexChanged()}
2873 \row \li QDateTimeEdit \li QDateTime \l{QDateTimeEdit::}{dateTime} \li \l{QDateTimeEdit::}{dateTimeChanged()}
2874 \row \li QLineEdit \li QString \l{QLineEdit::}{text} \li \l{QLineEdit::}{textChanged()}
2875 \row \li QListWidget \li int \l{QListWidget::}{currentRow} \li \l{QListWidget::}{currentRowChanged()}
2876 \row \li QSpinBox \li int \l{QSpinBox::}{value} \li \l{QSpinBox::}{valueChanged()}
2877 \endtable
2878
2879 \sa QWizardPage::registerField()
2880*/
2881void QWizard::setDefaultProperty(const char *className, const char *property,
2882 const char *changedSignal)
2883{
2884 Q_D(QWizard);
2885 for (int i = d->defaultPropertyTable.size() - 1; i >= 0; --i) {
2886 if (qstrcmp(d->defaultPropertyTable.at(i).className, className) == 0) {
2887 d->defaultPropertyTable.remove(i);
2888 break;
2889 }
2890 }
2891 d->defaultPropertyTable.append(QWizardDefaultProperty(className, property, changedSignal));
2892}
2893
2894/*!
2895 Sets the given \a widget to be shown on the left side of the wizard.
2896 For styles which use the WatermarkPixmap (ClassicStyle and ModernStyle)
2897 the side widget is displayed on top of the watermark, for other styles
2898 or when the watermark is not provided the side widget is displayed
2899 on the left side of the wizard.
2900
2901 Passing \nullptr shows no side widget.
2902
2903 When the \a widget is not \nullptr the wizard reparents it.
2904
2905 Any previous side widget is hidden.
2906
2907 You may call setSideWidget() with the same widget at different
2908 times.
2909
2910 All widgets set here will be deleted by the wizard when it is
2911 destroyed unless you separately reparent the widget after setting
2912 some other side widget (or \nullptr).
2913
2914 By default, no side widget is present.
2915*/
2916void QWizard::setSideWidget(QWidget *widget)
2917{
2918 Q_D(QWizard);
2919
2920 d->sideWidget = widget;
2921 if (d->watermarkLabel) {
2922 d->watermarkLabel->setSideWidget(widget);
2923 d->updateLayout();
2924 }
2925}
2926
2927/*!
2928 Returns the widget on the left side of the wizard or \nullptr.
2929
2930 By default, no side widget is present.
2931*/
2932QWidget *QWizard::sideWidget() const
2933{
2934 Q_D(const QWizard);
2935
2936 return d->sideWidget;
2937}
2938
2939/*!
2940 \reimp
2941*/
2942void QWizard::setVisible(bool visible)
2943{
2944 Q_D(QWizard);
2945 if (visible) {
2946 if (d->current == -1)
2947 restart();
2948 }
2949 QDialog::setVisible(visible);
2950}
2951
2952/*!
2953 \reimp
2954*/
2955QSize QWizard::sizeHint() const
2956{
2957 Q_D(const QWizard);
2958 QSize result = d->mainLayout->totalSizeHint();
2959 QSize extra(500, 360);
2960 if (d->wizStyle == MacStyle && d->current != -1) {
2961 QSize pixmap(currentPage()->pixmap(BackgroundPixmap).size());
2962 extra.setWidth(616);
2963 if (!pixmap.isNull()) {
2964 extra.setHeight(pixmap.height());
2965
2966 /*
2967 The width isn't always reliable as a size hint, as
2968 some wizard backgrounds just cover the leftmost area.
2969 Use a rule of thumb to determine if the width is
2970 reliable or not.
2971 */
2972 if (pixmap.width() >= pixmap.height())
2973 extra.setWidth(pixmap.width());
2974 }
2975 }
2976 return result.expandedTo(extra);
2977}
2978
2979/*!
2980 \fn void QWizard::currentIdChanged(int id)
2981
2982 This signal is emitted when the current page changes, with the new
2983 current \a id.
2984
2985 \sa currentId(), currentPage()
2986*/
2987
2988/*!
2989 \fn void QWizard::pageAdded(int id)
2990
2991 This signal is emitted whenever a page is added to the
2992 wizard. The page's \a id is passed as parameter.
2993
2994 \sa addPage(), setPage(), startId()
2995*/
2996
2997/*!
2998 \fn void QWizard::pageRemoved(int id)
2999
3000 This signal is emitted whenever a page is removed from the
3001 wizard. The page's \a id is passed as parameter.
3002
3003 \sa removePage(), startId()
3004*/
3005
3006/*!
3007 \fn void QWizard::helpRequested()
3008
3009 This signal is emitted when the user clicks the \uicontrol Help button.
3010
3011 By default, no \uicontrol Help button is shown. Call
3012 setOption(HaveHelpButton, true) to have one.
3013
3014 Example:
3015
3016 \snippet dialogs/licensewizard/licensewizard.cpp 0
3017 \dots
3018 \snippet dialogs/licensewizard/licensewizard.cpp 5
3019 \snippet dialogs/licensewizard/licensewizard.cpp 7
3020 \dots
3021 \snippet dialogs/licensewizard/licensewizard.cpp 8
3022 \codeline
3023 \snippet dialogs/licensewizard/licensewizard.cpp 10
3024 \dots
3025 \snippet dialogs/licensewizard/licensewizard.cpp 12
3026 \codeline
3027 \snippet dialogs/licensewizard/licensewizard.cpp 14
3028 \codeline
3029 \snippet dialogs/licensewizard/licensewizard.cpp 15
3030
3031 \sa customButtonClicked()
3032*/
3033
3034/*!
3035 \fn void QWizard::customButtonClicked(int which)
3036
3037 This signal is emitted when the user clicks a custom button. \a
3038 which can be CustomButton1, CustomButton2, or CustomButton3.
3039
3040 By default, no custom button is shown. Call setOption() with
3041 HaveCustomButton1, HaveCustomButton2, or HaveCustomButton3 to have
3042 one, and use setButtonText() or setButton() to configure it.
3043
3044 \sa helpRequested()
3045*/
3046
3047/*!
3048 Goes back to the previous page.
3049
3050 This is equivalent to pressing the \uicontrol Back button.
3051
3052 \sa next(), accept(), reject(), restart()
3053*/
3054void QWizard::back()
3055{
3056 Q_D(QWizard);
3057 int n = d->history.size() - 2;
3058 if (n < 0)
3059 return;
3060 d->switchToPage(d->history.at(n), QWizardPrivate::Backward);
3061}
3062
3063/*!
3064 Advances to the next page.
3065
3066 This is equivalent to pressing the \uicontrol Next or \uicontrol Commit button.
3067
3068 \sa nextId(), back(), accept(), reject(), restart()
3069*/
3070void QWizard::next()
3071{
3072 Q_D(QWizard);
3073
3074 if (d->current == -1)
3075 return;
3076
3077 if (validateCurrentPage()) {
3078 int next = nextId();
3079 if (next != -1) {
3080 if (Q_UNLIKELY(d->history.contains(next))) {
3081 qWarning("QWizard::next: Page %d already met", next);
3082 return;
3083 }
3084 if (Q_UNLIKELY(!d->pageMap.contains(next))) {
3085 qWarning("QWizard::next: No such page %d", next);
3086 return;
3087 }
3088 d->switchToPage(next, QWizardPrivate::Forward);
3089 }
3090 }
3091}
3092
3093/*!
3094 Sets currentId to \a id, without visiting the pages between currentId and \a id.
3095
3096 Returns without page change, if
3097 \list
3098 \li wizard holds no pages
3099 \li current page is invalid
3100 \li given page equals currentId()
3101 \li given page is out of range
3102 \endlist
3103
3104 Note: If pages have been forward skipped and \a id is 0, page visiting history
3105 will be deleted
3106*/
3107
3108void QWizard::setCurrentId(int id)
3109{
3110 Q_D(QWizard);
3111
3112 if (d->current == -1)
3113 return;
3114
3115 if (currentId() == id)
3116 return;
3117
3118 if (!validateCurrentPage())
3119 return;
3120
3121 if (id < 0 || Q_UNLIKELY(!d->pageMap.contains(id))) {
3122 qWarning("QWizard::setCurrentId: No such page: %d", id);
3123 return;
3124 }
3125
3126 d->switchToPage(id, (id < currentId()) ? QWizardPrivate::Backward : QWizardPrivate::Forward);
3127}
3128
3129/*!
3130 Restarts the wizard at the start page. This function is called automatically when the
3131 wizard is shown.
3132
3133 \sa startId()
3134*/
3135void QWizard::restart()
3136{
3137 Q_D(QWizard);
3138 d->disableUpdates();
3139 d->reset();
3140 d->switchToPage(startId(), QWizardPrivate::Forward);
3141 d->enableUpdates();
3142}
3143
3144/*!
3145 \reimp
3146*/
3147bool QWizard::event(QEvent *event)
3148{
3149 Q_D(QWizard);
3150 if (event->type() == QEvent::StyleChange) { // Propagate style
3151 d->setStyle(style());
3152 d->updateLayout();
3153 } else if (event->type() == QEvent::PaletteChange) { // Emitted on theme change
3154 d->updatePalette();
3155 }
3156#if QT_CONFIG(style_windowsvista)
3157 else if (event->type() == QEvent::Show && d->vistaInitPending) {
3158 d->vistaInitPending = false;
3159 d->wizStyle = AeroStyle;
3160 d->handleAeroStyleChange();
3161 }
3162 else if (d->isVistaThemeEnabled()) {
3163 if (event->type() == QEvent::Resize
3164 || event->type() == QEvent::LayoutDirectionChange) {
3165 const int buttonLeft = (layoutDirection() == Qt::RightToLeft
3166 ? width() - d->vistaHelper->backButton()->sizeHint().width()
3167 : 0);
3168
3169 d->vistaHelper->backButton()->move(buttonLeft,
3170 d->vistaHelper->backButton()->y());
3171 }
3172
3173 d->vistaHelper->mouseEvent(event);
3174 }
3175#endif
3176 return QDialog::event(event);
3177}
3178
3179/*!
3180 \reimp
3181*/
3182void QWizard::resizeEvent(QResizeEvent *event)
3183{
3184 Q_D(QWizard);
3185 int heightOffset = 0;
3186#if QT_CONFIG(style_windowsvista)
3187 if (d->isVistaThemeEnabled()) {
3188 heightOffset = d->vistaHelper->topOffset(this);
3189 heightOffset += d->vistaHelper->titleBarSize();
3190 }
3191#endif
3192 d->antiFlickerWidget->resize(event->size().width(), event->size().height() - heightOffset);
3193#if QT_CONFIG(style_windowsvista)
3194 if (d->isVistaThemeEnabled())
3195 d->vistaHelper->resizeEvent(event);
3196#endif
3197 QDialog::resizeEvent(event);
3198}
3199
3200/*!
3201 \reimp
3202*/
3203void QWizard::paintEvent(QPaintEvent * event)
3204{
3205 Q_D(QWizard);
3206 if (d->wizStyle == MacStyle && currentPage()) {
3207 QPixmap backgroundPixmap = currentPage()->pixmap(BackgroundPixmap);
3208 if (backgroundPixmap.isNull())
3209 return;
3210
3211 QStylePainter painter(this);
3212 painter.drawPixmap(0, (height() - backgroundPixmap.height()) / 2, backgroundPixmap);
3213 }
3214#if QT_CONFIG(style_windowsvista)
3215 else if (d->isVistaThemeEnabled()) {
3216 d->vistaHelper->paintEvent(event);
3217 }
3218#else
3219 Q_UNUSED(event);
3220#endif
3221}
3222
3223#if defined(Q_OS_WIN) || defined(Q_QDOC)
3224/*!
3225 \reimp
3226*/
3227bool QWizard::nativeEvent(const QByteArray &eventType, void *message, qintptr *result)
3228{
3229#if QT_CONFIG(style_windowsvista)
3230 Q_D(QWizard);
3231 if (d->isVistaThemeEnabled() && eventType == "windows_generic_MSG") {
3232 MSG *windowsMessage = static_cast<MSG *>(message);
3233 const bool winEventResult = d->vistaHelper->handleWinEvent(windowsMessage, result);
3234 if (d->vistaDirty) {
3235 // QTBUG-78300: When Qt::AA_NativeWindows is set, delay further
3236 // window creation until after the platform window creation events.
3237 if (windowsMessage->message == WM_GETICON) {
3238 d->vistaStateChanged = true;
3239 d->vistaDirty = false;
3240 setWizardStyle(AeroStyle);
3241 }
3242 }
3243 return winEventResult;
3244 } else {
3245 return QDialog::nativeEvent(eventType, message, result);
3246 }
3247#else
3248 return QDialog::nativeEvent(eventType, message, result);
3249#endif
3250}
3251#endif
3252
3253/*!
3254 \reimp
3255*/
3256void QWizard::done(int result)
3257{
3258 Q_D(QWizard);
3259 // canceling leaves the wizard in a known state
3260 if (result == Rejected) {
3261 d->reset();
3262 } else {
3263 if (!validateCurrentPage())
3264 return;
3265 }
3266 QDialog::done(result);
3267}
3268
3269/*!
3270 \fn void QWizard::initializePage(int id)
3271
3272 This virtual function is called by QWizard to prepare page \a id
3273 just before it is shown either as a result of QWizard::restart()
3274 being called, or as a result of the user clicking \uicontrol Next. (However, if the \l
3275 QWizard::IndependentPages option is set, this function is only
3276 called the first time the page is shown.)
3277
3278 By reimplementing this function, you can ensure that the page's
3279 fields are properly initialized based on fields from previous
3280 pages.
3281
3282 The default implementation calls QWizardPage::initializePage() on
3283 page(\a id).
3284
3285 \sa QWizardPage::initializePage(), cleanupPage()
3286*/
3287void QWizard::initializePage(int theid)
3288{
3289 QWizardPage *page = this->page(theid);
3290 if (page)
3291 page->initializePage();
3292}
3293
3294/*!
3295 \fn void QWizard::cleanupPage(int id)
3296
3297 This virtual function is called by QWizard to clean up page \a id just before the
3298 user leaves it by clicking \uicontrol Back (unless the \l QWizard::IndependentPages option is set).
3299
3300 The default implementation calls QWizardPage::cleanupPage() on
3301 page(\a id).
3302
3303 \sa QWizardPage::cleanupPage(), initializePage()
3304*/
3305void QWizard::cleanupPage(int theid)
3306{
3307 QWizardPage *page = this->page(theid);
3308 if (page)
3309 page->cleanupPage();
3310}
3311
3312/*!
3313 This virtual function is called by QWizard when the user clicks
3314 \uicontrol Next or \uicontrol Finish to perform some last-minute validation.
3315 If it returns \c true, the next page is shown (or the wizard
3316 finishes); otherwise, the current page stays up.
3317
3318 The default implementation calls QWizardPage::validatePage() on
3319 the currentPage().
3320
3321 When possible, it is usually better style to disable the \uicontrol
3322 Next or \uicontrol Finish button (by specifying \l{mandatory fields} or
3323 by reimplementing QWizardPage::isComplete()) than to reimplement
3324 validateCurrentPage().
3325
3326 \sa QWizardPage::validatePage(), currentPage()
3327*/
3328bool QWizard::validateCurrentPage()
3329{
3330 QWizardPage *page = currentPage();
3331 if (!page)
3332 return true;
3333
3334 return page->validatePage();
3335}
3336
3337/*!
3338 This virtual function is called by QWizard to find out which page
3339 to show when the user clicks the \uicontrol Next button.
3340
3341 The return value is the ID of the next page, or -1 if no page follows.
3342
3343 The default implementation calls QWizardPage::nextId() on the
3344 currentPage().
3345
3346 By reimplementing this function, you can specify a dynamic page
3347 order.
3348
3349 \sa QWizardPage::nextId(), currentPage()
3350*/
3351int QWizard::nextId() const
3352{
3353 const QWizardPage *page = currentPage();
3354 if (!page)
3355 return -1;
3356
3357 return page->nextId();
3358}
3359
3360/*!
3361 \class QWizardPage
3362 \brief The QWizardPage class is the base class for wizard pages.
3363
3364 \inmodule QtWidgets
3365
3366 QWizard represents a wizard. Each page is a QWizardPage. When
3367 you create your own wizards, you can use QWizardPage directly,
3368 or you can subclass it for more control.
3369
3370 A page has the following attributes, which are rendered by
3371 QWizard: a \l title, a \l subTitle, and a \l{setPixmap()}{set of
3372 pixmaps}. See \l{Elements of a Wizard Page} for details. Once a
3373 page is added to the wizard (using QWizard::addPage() or
3374 QWizard::setPage()), wizard() returns a pointer to the
3375 associated QWizard object.
3376
3377 Page provides five virtual functions that can be reimplemented to
3378 provide custom behavior:
3379
3380 \list
3381 \li initializePage() is called to initialize the page's contents
3382 when the user clicks the wizard's \uicontrol Next button. If you
3383 want to derive the page's default from what the user entered
3384 on previous pages, this is the function to reimplement.
3385 \li cleanupPage() is called to reset the page's contents when the
3386 user clicks the wizard's \uicontrol Back button.
3387 \li validatePage() validates the page when the user clicks \uicontrol
3388 Next or \uicontrol Finish. It is often used to show an error message
3389 if the user has entered incomplete or invalid information.
3390 \li nextId() returns the ID of the next page. It is useful when
3391 \l{creating non-linear wizards}, which allow different
3392 traversal paths based on the information provided by the user.
3393 \li isComplete() is called to determine whether the \uicontrol Next
3394 and/or \uicontrol Finish button should be enabled or disabled. If
3395 you reimplement isComplete(), also make sure that
3396 completeChanged() is emitted whenever the complete state
3397 changes.
3398 \endlist
3399
3400 Normally, the \uicontrol Next button and the \uicontrol Finish button of a
3401 wizard are mutually exclusive. If isFinalPage() returns \c true, \uicontrol
3402 Finish is available; otherwise, \uicontrol Next is available. By
3403 default, isFinalPage() is true only when nextId() returns -1. If
3404 you want to show \uicontrol Next and \uicontrol Final simultaneously for a
3405 page (letting the user perform an "early finish"), call
3406 setFinalPage(true) on that page. For wizards that support early
3407 finishes, you might also want to set the
3408 \l{QWizard::}{HaveNextButtonOnLastPage} and
3409 \l{QWizard::}{HaveFinishButtonOnEarlyPages} options on the
3410 wizard.
3411
3412 In many wizards, the contents of a page may affect the default
3413 values of the fields of a later page. To make it easy to
3414 communicate between pages, QWizard supports a \l{Registering and
3415 Using Fields}{"field" mechanism} that allows you to register a
3416 field (e.g., a QLineEdit) on a page and to access its value from
3417 any page. Fields are global to the entire wizard and make it easy
3418 for any single page to access information stored by another page,
3419 without having to put all the logic in QWizard or having the
3420 pages know explicitly about each other. Fields are registered
3421 using registerField() and can be accessed at any time using
3422 field() and setField().
3423
3424 \sa QWizard, {Trivial Wizard Example}, {License Wizard Example}
3425*/
3426
3427/*!
3428 Constructs a wizard page with the given \a parent.
3429
3430 When the page is inserted into a wizard using QWizard::addPage()
3431 or QWizard::setPage(), the parent is automatically set to be the
3432 wizard.
3433
3434 \sa wizard()
3435*/
3436QWizardPage::QWizardPage(QWidget *parent)
3437 : QWidget(*new QWizardPagePrivate, parent, { })
3438{
3439 connect(this, SIGNAL(completeChanged()), this, SLOT(_q_updateCachedCompleteState()));
3440}
3441
3442/*!
3443 Destructor.
3444*/
3445QWizardPage::~QWizardPage()
3446{
3447}
3448
3449/*!
3450 \property QWizardPage::title
3451 \brief the title of the page
3452
3453 The title is shown by the QWizard, above the actual page. All
3454 pages should have a title.
3455
3456 The title may be plain text or HTML, depending on the value of the
3457 \l{QWizard::titleFormat} property.
3458
3459 By default, this property contains an empty string.
3460
3461 \sa subTitle, {Elements of a Wizard Page}
3462*/
3463void QWizardPage::setTitle(const QString &title)
3464{
3465 Q_D(QWizardPage);
3466 d->title = title;
3467 if (d->wizard && d->wizard->currentPage() == this)
3468 d->wizard->d_func()->updateLayout();
3469}
3470
3471QString QWizardPage::title() const
3472{
3473 Q_D(const QWizardPage);
3474 return d->title;
3475}
3476
3477/*!
3478 \property QWizardPage::subTitle
3479 \brief the subtitle of the page
3480
3481 The subtitle is shown by the QWizard, between the title and the
3482 actual page. Subtitles are optional. In
3483 \l{QWizard::ClassicStyle}{ClassicStyle} and
3484 \l{QWizard::ModernStyle}{ModernStyle}, using subtitles is
3485 necessary to make the header appear. In
3486 \l{QWizard::MacStyle}{MacStyle}, the subtitle is shown as a text
3487 label just above the actual page.
3488
3489 The subtitle may be plain text or HTML, depending on the value of
3490 the \l{QWizard::subTitleFormat} property.
3491
3492 By default, this property contains an empty string.
3493
3494 \sa title, QWizard::IgnoreSubTitles, {Elements of a Wizard Page}
3495*/
3496void QWizardPage::setSubTitle(const QString &subTitle)
3497{
3498 Q_D(QWizardPage);
3499 d->subTitle = subTitle;
3500 if (d->wizard && d->wizard->currentPage() == this)
3501 d->wizard->d_func()->updateLayout();
3502}
3503
3504QString QWizardPage::subTitle() const
3505{
3506 Q_D(const QWizardPage);
3507 return d->subTitle;
3508}
3509
3510/*!
3511 Sets the pixmap for role \a which to \a pixmap.
3512
3513 The pixmaps are used by QWizard when displaying a page. Which
3514 pixmaps are actually used depend on the \l{Wizard Look and
3515 Feel}{wizard style}.
3516
3517 Pixmaps can also be set for the entire wizard using
3518 QWizard::setPixmap(), in which case they apply for all pages that
3519 don't specify a pixmap.
3520
3521 \sa QWizard::setPixmap(), {Elements of a Wizard Page}
3522*/
3523void QWizardPage::setPixmap(QWizard::WizardPixmap which, const QPixmap &pixmap)
3524{
3525 Q_D(QWizardPage);
3526 Q_ASSERT(uint(which) < QWizard::NPixmaps);
3527 d->pixmaps[which] = pixmap;
3528 if (d->wizard && d->wizard->currentPage() == this)
3529 d->wizard->d_func()->updatePixmap(which);
3530}
3531
3532/*!
3533 Returns the pixmap set for role \a which.
3534
3535 Pixmaps can also be set for the entire wizard using
3536 QWizard::setPixmap(), in which case they apply for all pages that
3537 don't specify a pixmap.
3538
3539 \sa QWizard::pixmap(), {Elements of a Wizard Page}
3540*/
3541QPixmap QWizardPage::pixmap(QWizard::WizardPixmap which) const
3542{
3543 Q_D(const QWizardPage);
3544 Q_ASSERT(uint(which) < QWizard::NPixmaps);
3545
3546 const QPixmap &pixmap = d->pixmaps[which];
3547 if (!pixmap.isNull())
3548 return pixmap;
3549
3550 if (wizard())
3551 return wizard()->pixmap(which);
3552
3553 return pixmap;
3554}
3555
3556/*!
3557 This virtual function is called by QWizard::initializePage() to
3558 prepare the page just before it is shown either as a result of QWizard::restart()
3559 being called, or as a result of the user clicking \uicontrol Next.
3560 (However, if the \l QWizard::IndependentPages option is set, this function is only
3561 called the first time the page is shown.)
3562
3563 By reimplementing this function, you can ensure that the page's
3564 fields are properly initialized based on fields from previous
3565 pages. For example:
3566
3567 \snippet dialogs/licensewizard/licensewizard.cpp 27
3568
3569 The default implementation does nothing.
3570
3571 \sa QWizard::initializePage(), cleanupPage(), QWizard::IndependentPages
3572*/
3573void QWizardPage::initializePage()
3574{
3575}
3576
3577/*!
3578 This virtual function is called by QWizard::cleanupPage() when
3579 the user leaves the page by clicking \uicontrol Back (unless the \l QWizard::IndependentPages
3580 option is set).
3581
3582 The default implementation resets the page's fields to their
3583 original values (the values they had before initializePage() was
3584 called).
3585
3586 \sa QWizard::cleanupPage(), initializePage(), QWizard::IndependentPages
3587*/
3588void QWizardPage::cleanupPage()
3589{
3590 Q_D(QWizardPage);
3591 if (d->wizard) {
3592 const QList<QWizardField> &fields = d->wizard->d_func()->fields;
3593 for (const auto &field : fields) {
3594 if (field.page == this)
3595 field.object->setProperty(field.property, field.initialValue);
3596 }
3597 }
3598}
3599
3600/*!
3601 This virtual function is called by QWizard::validateCurrentPage()
3602 when the user clicks \uicontrol Next or \uicontrol Finish to perform some
3603 last-minute validation. If it returns \c true, the next page is shown
3604 (or the wizard finishes); otherwise, the current page stays up.
3605
3606 The default implementation returns \c true.
3607
3608 When possible, it is usually better style to disable the \uicontrol
3609 Next or \uicontrol Finish button (by specifying \l{mandatory fields} or
3610 reimplementing isComplete()) than to reimplement validatePage().
3611
3612 \sa QWizard::validateCurrentPage(), isComplete()
3613*/
3614bool QWizardPage::validatePage()
3615{
3616 return true;
3617}
3618
3619/*!
3620 This virtual function is called by QWizard to determine whether
3621 the \uicontrol Next or \uicontrol Finish button should be enabled or
3622 disabled.
3623
3624 The default implementation returns \c true if all \l{mandatory
3625 fields} are filled; otherwise, it returns \c false.
3626
3627 If you reimplement this function, make sure to emit completeChanged(),
3628 from the rest of your implementation, whenever the value of isComplete()
3629 changes. This ensures that QWizard updates the enabled or disabled state of
3630 its buttons. An example of the reimplementation is
3631 available \l{http://doc.qt.io/archives/qq/qq22-qwizard.html#validatebeforeitstoolate}
3632 {here}.
3633
3634 \sa completeChanged(), isFinalPage()
3635*/
3636bool QWizardPage::isComplete() const
3637{
3638 Q_D(const QWizardPage);
3639
3640 if (!d->wizard)
3641 return true;
3642
3643 const QList<QWizardField> &wizardFields = d->wizard->d_func()->fields;
3644 const auto end = wizardFields.crend();
3645 for (auto it = wizardFields.crbegin(); it != end; ++it) {
3646 const QWizardField &field = *it;
3647 if (field.page == this && field.mandatory) {
3648 QVariant value = field.object->property(field.property);
3649 if (value == field.initialValue)
3650 return false;
3651
3652#if QT_CONFIG(lineedit)
3653 if (QLineEdit *lineEdit = qobject_cast<QLineEdit *>(field.object)) {
3654 if (!lineEdit->hasAcceptableInput())
3655 return false;
3656 }
3657#endif
3658#if QT_CONFIG(spinbox)
3659 if (QAbstractSpinBox *spinBox = qobject_cast<QAbstractSpinBox *>(field.object)) {
3660 if (!spinBox->hasAcceptableInput())
3661 return false;
3662 }
3663#endif
3664 }
3665 }
3666 return true;
3667}
3668
3669/*!
3670 Explicitly sets this page to be final if \a finalPage is true.
3671
3672 After calling setFinalPage(true), isFinalPage() returns \c true and the \uicontrol
3673 Finish button is visible (and enabled if isComplete() returns
3674 true).
3675
3676 After calling setFinalPage(false), isFinalPage() returns \c true if
3677 nextId() returns -1; otherwise, it returns \c false.
3678
3679 \sa isComplete(), QWizard::HaveFinishButtonOnEarlyPages
3680*/
3681void QWizardPage::setFinalPage(bool finalPage)
3682{
3683 Q_D(QWizardPage);
3684 d->explicitlyFinal = finalPage;
3685 QWizard *wizard = this->wizard();
3686 if (wizard && wizard->currentPage() == this)
3687 wizard->d_func()->updateCurrentPage();
3688}
3689
3690/*!
3691 This function is called by QWizard to determine whether the \uicontrol
3692 Finish button should be shown for this page or not.
3693
3694 By default, it returns \c true if there is no next page
3695 (i.e., nextId() returns -1); otherwise, it returns \c false.
3696
3697 By explicitly calling setFinalPage(true), you can let the user perform an
3698 "early finish".
3699
3700 \sa isComplete(), QWizard::HaveFinishButtonOnEarlyPages
3701*/
3702bool QWizardPage::isFinalPage() const
3703{
3704 Q_D(const QWizardPage);
3705 if (d->explicitlyFinal)
3706 return true;
3707
3708 QWizard *wizard = this->wizard();
3709 if (wizard && wizard->currentPage() == this) {
3710 // try to use the QWizard implementation if possible
3711 return wizard->nextId() == -1;
3712 } else {
3713 return nextId() == -1;
3714 }
3715}
3716
3717/*!
3718 Sets this page to be a commit page if \a commitPage is true; otherwise,
3719 sets it to be a normal page.
3720
3721 A commit page is a page that represents an action which cannot be undone
3722 by clicking \uicontrol Back or \uicontrol Cancel.
3723
3724 A \uicontrol Commit button replaces the \uicontrol Next button on a commit page. Clicking this
3725 button simply calls QWizard::next() just like clicking \uicontrol Next does.
3726
3727 A page entered directly from a commit page has its \uicontrol Back button disabled.
3728
3729 \sa isCommitPage()
3730*/
3731void QWizardPage::setCommitPage(bool commitPage)
3732{
3733 Q_D(QWizardPage);
3734 d->commit = commitPage;
3735 QWizard *wizard = this->wizard();
3736 if (wizard && wizard->currentPage() == this)
3737 wizard->d_func()->updateCurrentPage();
3738}
3739
3740/*!
3741 Returns \c true if this page is a commit page; otherwise returns \c false.
3742
3743 \sa setCommitPage()
3744*/
3745bool QWizardPage::isCommitPage() const
3746{
3747 Q_D(const QWizardPage);
3748 return d->commit;
3749}
3750
3751/*!
3752 Sets the text on button \a which to be \a text on this page.
3753
3754 By default, the text on buttons depends on the QWizard::wizardStyle,
3755 but may be redefined for the wizard as a whole using QWizard::setButtonText().
3756
3757 \sa buttonText(), QWizard::setButtonText(), QWizard::buttonText()
3758*/
3759void QWizardPage::setButtonText(QWizard::WizardButton which, const QString &text)
3760{
3761 Q_D(QWizardPage);
3762 d->buttonCustomTexts.insert(which, text);
3763 if (wizard() && wizard()->currentPage() == this && wizard()->d_func()->btns[which])
3764 wizard()->d_func()->btns[which]->setText(text);
3765}
3766
3767/*!
3768 Returns the text on button \a which on this page.
3769
3770 If a text has ben set using setButtonText(), this text is returned.
3771 Otherwise, if a text has been set using QWizard::setButtonText(),
3772 this text is returned.
3773
3774 By default, the text on buttons depends on the QWizard::wizardStyle.
3775 For example, on \macos, the \uicontrol Next button is called \uicontrol
3776 Continue.
3777
3778 \sa setButtonText(), QWizard::buttonText(), QWizard::setButtonText()
3779*/
3780QString QWizardPage::buttonText(QWizard::WizardButton which) const
3781{
3782 Q_D(const QWizardPage);
3783
3784 if (d->buttonCustomTexts.contains(which))
3785 return d->buttonCustomTexts.value(which);
3786
3787 if (wizard())
3788 return wizard()->buttonText(which);
3789
3790 return QString();
3791}
3792
3793/*!
3794 This virtual function is called by QWizard::nextId() to find
3795 out which page to show when the user clicks the \uicontrol Next button.
3796
3797 The return value is the ID of the next page, or -1 if no page follows.
3798
3799 By default, this function returns the lowest ID greater than the ID
3800 of the current page, or -1 if there is no such ID.
3801
3802 By reimplementing this function, you can specify a dynamic page
3803 order. For example:
3804
3805 \snippet dialogs/licensewizard/licensewizard.cpp 18
3806
3807 \sa QWizard::nextId()
3808*/
3809int QWizardPage::nextId() const
3810{
3811 Q_D(const QWizardPage);
3812
3813 if (!d->wizard)
3814 return -1;
3815
3816 bool foundCurrentPage = false;
3817
3818 const QWizardPrivate::PageMap &pageMap = d->wizard->d_func()->pageMap;
3819 QWizardPrivate::PageMap::const_iterator i = pageMap.constBegin();
3820 QWizardPrivate::PageMap::const_iterator end = pageMap.constEnd();
3821
3822 for (; i != end; ++i) {
3823 if (i.value() == this) {
3824 foundCurrentPage = true;
3825 } else if (foundCurrentPage) {
3826 return i.key();
3827 }
3828 }
3829 return -1;
3830}
3831
3832/*!
3833 \fn void QWizardPage::completeChanged()
3834
3835 This signal is emitted whenever the complete state of the page
3836 (i.e., the value of isComplete()) changes.
3837
3838 If you reimplement isComplete(), make sure to emit
3839 completeChanged() whenever the value of isComplete() changes, to
3840 ensure that QWizard updates the enabled or disabled state of its
3841 buttons.
3842
3843 \sa isComplete()
3844*/
3845
3846/*!
3847 Sets the value of the field called \a name to \a value.
3848
3849 This function can be used to set fields on any page of the wizard.
3850 It is equivalent to calling
3851 wizard()->\l{QWizard::setField()}{setField(\a name, \a value)}.
3852
3853 \sa QWizard::setField(), field(), registerField()
3854*/
3855void QWizardPage::setField(const QString &name, const QVariant &value)
3856{
3857 Q_D(QWizardPage);
3858 if (!d->wizard)
3859 return;
3860 d->wizard->setField(name, value);
3861}
3862
3863/*!
3864 Returns the value of the field called \a name.
3865
3866 This function can be used to access fields on any page of the
3867 wizard. It is equivalent to calling
3868 wizard()->\l{QWizard::field()}{field(\a name)}.
3869
3870 Example:
3871
3872 \snippet dialogs/licensewizard/licensewizard.cpp accessField
3873
3874 \sa QWizard::field(), setField(), registerField()
3875*/
3876QVariant QWizardPage::field(const QString &name) const
3877{
3878 Q_D(const QWizardPage);
3879 if (!d->wizard)
3880 return QVariant();
3881 return d->wizard->field(name);
3882}
3883
3884/*!
3885 Creates a field called \a name associated with the given \a
3886 property of the given \a widget. From then on, that property
3887 becomes accessible using field() and setField().
3888
3889 Fields are global to the entire wizard and make it easy for any
3890 single page to access information stored by another page, without
3891 having to put all the logic in QWizard or having the pages know
3892 explicitly about each other.
3893
3894 If \a name ends with an asterisk (\c *), the field is a mandatory
3895 field. When a page has mandatory fields, the \uicontrol Next and/or
3896 \uicontrol Finish buttons are enabled only when all mandatory fields
3897 are filled. This requires a \a changedSignal to be specified, to
3898 tell QWizard to recheck the value stored by the mandatory field.
3899
3900 QWizard knows the most common Qt widgets. For these (or their
3901 subclasses), you don't need to specify a \a property or a \a
3902 changedSignal. The table below lists these widgets:
3903
3904 \table
3905 \header \li Widget \li Property \li Change Notification Signal
3906 \row \li QAbstractButton \li bool \l{QAbstractButton::}{checked} \li \l{QAbstractButton::}{toggled()}
3907 \row \li QAbstractSlider \li int \l{QAbstractSlider::}{value} \li \l{QAbstractSlider::}{valueChanged()}
3908 \row \li QComboBox \li int \l{QComboBox::}{currentIndex} \li \l{QComboBox::}{currentIndexChanged()}
3909 \row \li QDateTimeEdit \li QDateTime \l{QDateTimeEdit::}{dateTime} \li \l{QDateTimeEdit::}{dateTimeChanged()}
3910 \row \li QLineEdit \li QString \l{QLineEdit::}{text} \li \l{QLineEdit::}{textChanged()}
3911 \row \li QListWidget \li int \l{QListWidget::}{currentRow} \li \l{QListWidget::}{currentRowChanged()}
3912 \row \li QSpinBox \li int \l{QSpinBox::}{value} \li \l{QSpinBox::}{valueChanged()}
3913 \endtable
3914
3915 You can use QWizard::setDefaultProperty() to add entries to this
3916 table or to override existing entries.
3917
3918 To consider a field "filled", QWizard simply checks that their
3919 current value doesn't equal their original value (the value they
3920 had before initializePage() was called). For QLineEdit, it also
3921 checks that
3922 \l{QLineEdit::hasAcceptableInput()}{hasAcceptableInput()} returns
3923 true, to honor any validator or mask.
3924
3925 QWizard's mandatory field mechanism is provided for convenience.
3926 It can be bypassed by reimplementing QWizardPage::isComplete().
3927
3928 \sa field(), setField(), QWizard::setDefaultProperty()
3929*/
3930void QWizardPage::registerField(const QString &name, QWidget *widget, const char *property,
3931 const char *changedSignal)
3932{
3933 Q_D(QWizardPage);
3934 QWizardField field(this, name, widget, property, changedSignal);
3935 if (d->wizard) {
3936 d->wizard->d_func()->addField(field);
3937 } else {
3938 d->pendingFields += field;
3939 }
3940}
3941
3942/*!
3943 Returns the wizard associated with this page, or \nullptr if this page
3944 hasn't been inserted into a QWizard yet.
3945
3946 \sa QWizard::addPage(), QWizard::setPage()
3947*/
3948QWizard *QWizardPage::wizard() const
3949{
3950 Q_D(const QWizardPage);
3951 return d->wizard;
3952}
3953
3954QT_END_NAMESPACE
3955
3956#include "moc_qwizard.cpp"
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:444
void setSideWidget(QWidget *widget)
Definition qwizard.cpp:450
QWatermarkLabel(QWidget *parent, QWidget *sideWidget)
Definition qwizard.cpp:438
QWidget * sideWidget() const
Definition qwizard.cpp:461
QWizardAntiFlickerWidget(QWizard *wizard, QWizardPrivate *)
Definition qwizard.cpp:525
QWizardDefaultProperty(const char *className, const char *property, const char *changedSignal)
Definition qwizard.cpp:144
QByteArray changedSignal
Definition qwizard.cpp:141
QString name
Definition qwizard.cpp:161
void resolve(const QList< QWizardDefaultProperty > &defaultPropertyTable)
Definition qwizard.cpp:181
QWizardField(QWizardPage *page, const QString &spec, QObject *object, const char *property, const char *changedSignal)
Definition qwizard.cpp:170
void findProperty(const QWizardDefaultProperty *properties, int propertyCount)
Definition qwizard.cpp:188
QByteArray property
Definition qwizard.cpp:164
QByteArray changedSignal
Definition qwizard.cpp:165
QVariant initialValue
Definition qwizard.cpp:166
QWizardPage * page
Definition qwizard.cpp:160
QObject * object
Definition qwizard.cpp:163
void paintEvent(QPaintEvent *event) override
This event handler can be reimplemented in a subclass to receive paint events passed in event.
Definition qwizard.cpp:396
void setup(const QWizardLayoutInfo &info, const QString &title, const QString &subTitle, const QPixmap &logo, const QPixmap &banner, std::optional< Qt::TextFormat > titleFormat, std::optional< Qt::TextFormat > subTitleFormat, QWizard::WizardOptions wizardOptions)
Definition qwizard.cpp:332
QWizardHeader(RulerType, QWidget *parent=nullptr)
Definition qwizard.cpp:255
QWizardHeader(QWidget *parent=nullptr)
Definition qwizard.cpp:282
bool operator!=(const QWizardLayoutInfo &other) const
Definition qwizard.cpp:224
bool operator==(const QWizardLayoutInfo &other) const
Definition qwizard.cpp:227
TriState completeState
Definition qwizard.cpp:485
void _q_maybeEmitCompleteChanged()
Definition qwizard.cpp:500
QMap< int, QString > buttonCustomTexts
Definition qwizard.cpp:489
QEnumIndexedArrayFor< QPixmap, QWizard::NPixmaps > pixmaps
Definition qwizard.cpp:483
void _q_updateCachedCompleteState()
Definition qwizard.cpp:508
bool cachedIsComplete() const
Definition qwizard.cpp:492
QList< QWizardField > pendingFields
Definition qwizard.cpp:484
QMap< int, QString > buttonCustomTexts
Definition qwizard.cpp:592
QList< int > history
Definition qwizard.cpp:581
QMap< QString, int > fieldIndexMap
Definition qwizard.cpp:579
void setStyle(QStyle *style)
Definition qwizard.cpp:1735
PageMap pageMap
Definition qwizard.cpp:577
QGridLayout * mainLayout
Definition qwizard.cpp:624
QList< QWizardDefaultProperty > defaultPropertyTable
Definition qwizard.cpp:580
bool buttonLayoutContains(QWizard::WizardButton which)
Definition qwizard.cpp:1533
void updateCurrentPage()
Definition qwizard.cpp:1352
std::optional< Qt::TextFormat > subTitleFmt
Definition qwizard.cpp:596
void _q_updateButtonStates()
Definition qwizard.cpp:1657
QVBoxLayout * pageVBoxLayout
Definition qwizard.cpp:622
QWatermarkLabel * watermarkLabel
Definition qwizard.cpp:615
QWizardLayoutInfo layoutInfoForCurrentPage()
Definition qwizard.cpp:894
bool startSetByUser
Definition qwizard.cpp:583
void connectButton(QWizard::WizardButton which) const
Definition qwizard.cpp:1421
void removeFieldAt(int index)
Definition qwizard.cpp:779
std::optional< Qt::TextFormat > titleFmt
Definition qwizard.cpp:595
QLabel * subTitleLabel
Definition qwizard.cpp:619
QFrame * pageFrame
Definition qwizard.cpp:617
QLabel * titleLabel
Definition qwizard.cpp:618
void recreateLayout(const QWizardLayoutInfo &info)
Definition qwizard.cpp:955
QWizardAntiFlickerWidget * antiFlickerWidget
Definition qwizard.cpp:611
QWizardHeader * headerWidget
Definition qwizard.cpp:614
void updateLayout()
Definition qwizard.cpp:1229
QHBoxLayout * buttonLayout
Definition qwizard.cpp:623
void updateMinMaxSizes(const QWizardLayoutInfo &info)
Definition qwizard.cpp:1316
void _q_emitCustomButtonClicked()
Definition qwizard.cpp:1645
void setButtonLayout(const QWizard::WizardButton *array, int size)
Definition qwizard.cpp:1500
bool isVistaThemeEnabled() const
Definition qwizard.cpp:1618
void updatePixmap(QWizard::WizardPixmap which)
Definition qwizard.cpp:1538
QWidget * sideWidget
Definition qwizard.cpp:616
void _q_handleFieldObjectDestroyed(QObject *)
Definition qwizard.cpp:1708
void switchToPage(int newId, Direction direction)
Definition qwizard.cpp:794
QList< QWizard::WizardButton > buttonsCustomLayout
Definition qwizard.cpp:594
void enableUpdates()
Definition qwizard.cpp:1636
int disableUpdatesCount
Definition qwizard.cpp:588
QPixmap defaultPixmaps[QWizard::NPixmaps]
Definition qwizard.cpp:597
QWidget * placeholderWidget2
Definition qwizard.cpp:613
QWizardRuler * bottomRuler
Definition qwizard.cpp:620
void updateButtonTexts()
Definition qwizard.cpp:1431
void updateButtonLayout()
Definition qwizard.cpp:1460
QList< QWizardField > fields
Definition qwizard.cpp:578
bool ensureButton(QWizard::WizardButton which) const
Definition qwizard.cpp:1392
void updatePalette()
Definition qwizard.cpp:1292
bool buttonsHaveCustomLayout
Definition qwizard.cpp:593
void cleanupPagesNotInHistory()
Definition qwizard.cpp:743
void disableUpdates()
Definition qwizard.cpp:1627
QWidget * placeholderWidget1
Definition qwizard.cpp:612
void addField(const QWizardField &field)
Definition qwizard.cpp:757
QWizardLayoutInfo layoutInfo
Definition qwizard.cpp:587
QWizardRuler(QWidget *parent=nullptr)
Definition qwizard.cpp:431
Combined button and popup list for selecting options.
static const char * buttonSlots(QWizard::WizardButton which)
Definition qwizard.cpp:870
static QString buttonDefaultText(int wstyle, int which, const QWizardPrivate *wizardPrivate)
Definition qwizard.cpp:642
static QString object_name_for_button(QWizard::WizardButton which)
Definition qwizard.cpp:1366
Q_DECLARE_TYPEINFO(QWizardDefaultProperty, Q_RELOCATABLE_TYPE)
const int ModernHeaderTopMargin
Definition qwizard.cpp:53
static void changeSpacerSize(QLayout *layout, int index, int width, int height)
Definition qwizard.cpp:61
const int MacLayoutLeftMargin
Definition qwizard.cpp:56
const int GapBetweenLogoAndRightEdge
Definition qwizard.cpp:52
static bool objectInheritsXAndXIsCloserThanY(const QObject *object, const QByteArray &classX, const QByteArray &classY)
Definition qwizard.cpp:87
static QWidget * iWantTheFocus(QWidget *ancestor)
Definition qwizard.cpp:69
Q_DECLARE_TYPEINFO(QWizardField, Q_RELOCATABLE_TYPE)
const int MacLayoutBottomMargin
Definition qwizard.cpp:59
const int MacLayoutRightMargin
Definition qwizard.cpp:58
static const char * changed_signal(int which)
Definition qwizard.cpp:116
const size_t NFallbackDefaultProperties
Definition qwizard.cpp:114
const int ClassicHMargin
Definition qwizard.cpp:54
const int MacButtonTopMargin
Definition qwizard.cpp:55