diff options
author | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2016-01-23 20:05:55 +0100 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2016-01-28 05:31:31 +0000 |
commit | 8d8bc174243215715cb0e9143f230158c357ece1 (patch) | |
tree | 357b7dd6d706683401dc65d16d5899bc364517de /tests | |
parent | 44ecf7891eeb18b4e22bb5bcc8d0ccea3c9f92df (diff) |
Add manual test for embedding in QWidgets.
Add a manual test similar to that in Qt Quick Controls.
Change-Id: Ic93026f3b1333613be43b8827ddf3702c2ef5b70
Reviewed-by: Alessandro Portale <alessandro.portale@theqtcompany.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/manual/manual.pro | 2 | ||||
-rw-r--r-- | tests/manual/viewinqwidget/main.cpp | 89 | ||||
-rw-r--r-- | tests/manual/viewinqwidget/main.qml | 49 | ||||
-rw-r--r-- | tests/manual/viewinqwidget/viewinqwidget.pro | 6 | ||||
-rw-r--r-- | tests/manual/viewinqwidget/viewinqwidget.qrc | 5 |
5 files changed, 151 insertions, 0 deletions
diff --git a/tests/manual/manual.pro b/tests/manual/manual.pro index b974ae29..a85fd870 100644 --- a/tests/manual/manual.pro +++ b/tests/manual/manual.pro @@ -3,3 +3,5 @@ SUBDIRS += \ gifs \ fonts \ testbench + +qtHaveModule(widgets): SUBDIRS += viewinqwidget diff --git a/tests/manual/viewinqwidget/main.cpp b/tests/manual/viewinqwidget/main.cpp new file mode 100644 index 00000000..ff949544 --- /dev/null +++ b/tests/manual/viewinqwidget/main.cpp @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QApplication> +#include <QHBoxLayout> +#include <QVBoxLayout> +#include <QDebug> +#include <QDesktopWidget> +#include <QGroupBox> +#include <QQmlApplicationEngine> +#include <QQmlError> +#include <QQuickView> +#include <QQuickWidget> + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + QWidget widget; + widget.setWindowTitle(QT_VERSION_STR); + + QHBoxLayout *hLayout = new QHBoxLayout(&widget); + QGroupBox *groupBox = new QGroupBox("QuickWidget", &widget); + QVBoxLayout *vLayout = new QVBoxLayout(groupBox); + QQuickWidget *quickWidget = new QQuickWidget(groupBox); + quickWidget->setMinimumSize(360, 520); + vLayout->addWidget(quickWidget); + quickWidget->setResizeMode(QQuickWidget::SizeRootObjectToView); + quickWidget->setSource(QUrl(QLatin1String("qrc:/main.qml"))); + if (quickWidget->status() == QQuickWidget::Error) { + qWarning() << quickWidget->errors(); + return 1; + } + hLayout->addWidget(groupBox); + + const QUrl gallerySource(QLatin1String("qrc:/gallery.qml")); + QQmlApplicationEngine engine(gallerySource); + QObject *root = engine.rootObjects().value(0, Q_NULLPTR); + if (!root || !root->isWindowType()) { + qWarning() << "Load error" << gallerySource; + return 1; + } + groupBox = new QGroupBox("QQuickView/createWindowContainer", &widget); + vLayout = new QVBoxLayout(groupBox); + QWidget *container = QWidget::createWindowContainer(qobject_cast<QWindow *>(root), groupBox); + container->setMinimumSize(360, 520); + vLayout->addWidget(container); + hLayout->addWidget(groupBox); + + const QRect availableGeometry = QApplication::desktop()->availableGeometry(&widget); + widget.move(availableGeometry.center() - QPoint(widget.sizeHint().width() / 2, widget.sizeHint().height() / 2)); + + widget.show(); + + return app.exec(); +} diff --git a/tests/manual/viewinqwidget/main.qml b/tests/manual/viewinqwidget/main.qml new file mode 100644 index 00000000..36a0b133 --- /dev/null +++ b/tests/manual/viewinqwidget/main.qml @@ -0,0 +1,49 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.6 +import Qt.labs.controls 1.0 + +Item { + visible: true + width: 360 + height: 520 + + ComboBox { + model: ["First", "Second", "Third"] + anchors.centerIn: parent + } +} diff --git a/tests/manual/viewinqwidget/viewinqwidget.pro b/tests/manual/viewinqwidget/viewinqwidget.pro new file mode 100644 index 00000000..9b7cba00 --- /dev/null +++ b/tests/manual/viewinqwidget/viewinqwidget.pro @@ -0,0 +1,6 @@ +QT += qml quick widgets quickwidgets +TARGET = viewinqwidget +SOURCES += $$PWD/main.cpp +OTHER_FILES += main.qml +RESOURCES += viewinqwidget.qrc \ + ../../../examples/controls/gallery/gallery.qrc diff --git a/tests/manual/viewinqwidget/viewinqwidget.qrc b/tests/manual/viewinqwidget/viewinqwidget.qrc new file mode 100644 index 00000000..5f6483ac --- /dev/null +++ b/tests/manual/viewinqwidget/viewinqwidget.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/"> + <file>main.qml</file> + </qresource> +</RCC> |