diff options
Diffstat (limited to 'tests/manual/dialogs/wizardpanel.cpp')
-rw-r--r-- | tests/manual/dialogs/wizardpanel.cpp | 55 |
1 files changed, 23 insertions, 32 deletions
diff --git a/tests/manual/dialogs/wizardpanel.cpp b/tests/manual/dialogs/wizardpanel.cpp index 4edb10afb8..5e413960e3 100644 --- a/tests/manual/dialogs/wizardpanel.cpp +++ b/tests/manual/dialogs/wizardpanel.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include "wizardpanel.h" @@ -216,7 +191,7 @@ class WizardPage : public QWizardPage public: explicit WizardPage(const QString &title, QWidget *parent = nullptr); - void initializePage(); + void initializePage() override; private: WizardStyleControl *m_styleControl; @@ -254,7 +229,7 @@ Wizard::Wizard(QWidget *parent, Qt::WindowFlags flags) addPage(new WizardPage(tr("Page 3"), this)); } -// A dialog using a Wizard as child widget (emulating Qt Designer). +// A dialog using a Wizard as child widget (emulating Qt Widgets Designer). class WizardEmbeddingDialog : public QDialog { public: explicit WizardEmbeddingDialog(QWidget *parent = nullptr); @@ -296,8 +271,14 @@ WizardPanel::WizardPanel(QWidget *parent) gridLayout->addWidget(m_styleControl, 0, 1); QGroupBox *buttonGroupBox = new QGroupBox(this); QVBoxLayout *vLayout = new QVBoxLayout(buttonGroupBox); - QPushButton *button = new QPushButton(tr("Show modal"), this); - connect(button, SIGNAL(clicked()), this, SLOT(showModal())); + QPushButton *button = new QPushButton(tr("Exec modal"), this); + connect(button, SIGNAL(clicked()), this, SLOT(execModal())); + vLayout->addWidget(button); + button = new QPushButton(tr("Show application modal"), this); + connect(button, &QPushButton::clicked, [this]() { showModal(Qt::ApplicationModal); }); + vLayout->addWidget(button); + button = new QPushButton(tr("Show window modal"), this); + connect(button, &QPushButton::clicked, [this]() { showModal(Qt::WindowModal); }); vLayout->addWidget(button); button = new QPushButton(tr("Show non-modal"), this); connect(button, SIGNAL(clicked()), this, SLOT(showNonModal())); @@ -310,13 +291,23 @@ WizardPanel::WizardPanel(QWidget *parent) gridLayout->addWidget(buttonGroupBox, 1, 1); } -void WizardPanel::showModal() +void WizardPanel::execModal() { Wizard wizard(this); applyParameters(&wizard); wizard.exec(); } +void WizardPanel::showModal(Qt::WindowModality modality) +{ + Wizard *wizard = new Wizard(this); + applyParameters(wizard); + wizard->setModal(true); + wizard->setAttribute(Qt::WA_DeleteOnClose); + wizard->setWindowModality(modality); + wizard->show(); +} + void WizardPanel::showNonModal() { Wizard *wizard = new Wizard(this); |