From 4c065b497e63832cf610cc06d67a7b40965154fb Mon Sep 17 00:00:00 2001 From: Robin Burchell Date: Tue, 6 Jan 2015 19:29:08 +0100 Subject: qmltime: Remove widgets dependency. To do this easily while retaining the meaning of the -parent flag, we add a private export to QQuickView so that we can set the root object. Change-Id: Iabb2b998816a6fdfcc8417f679c96f04910b8202 Reviewed-by: Simon Hausmann Reviewed-by: Shawn Rutledge Reviewed-by: Michael Brasser --- src/quick/items/qquickview_p.h | 2 +- tests/benchmarks/qml/qmltime/qmltime.cpp | 34 +++++++++++++++++--------------- tests/benchmarks/qml/qmltime/qmltime.pro | 3 ++- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/quick/items/qquickview_p.h b/src/quick/items/qquickview_p.h index 6f970f959d..71b39f5b0f 100644 --- a/src/quick/items/qquickview_p.h +++ b/src/quick/items/qquickview_p.h @@ -70,7 +70,7 @@ class QQmlError; class QQuickItem; class QQmlComponent; -class QQuickViewPrivate : public QQuickWindowPrivate, +class Q_QUICK_PRIVATE_EXPORT QQuickViewPrivate : public QQuickWindowPrivate, public QQuickItemChangeListener { Q_DECLARE_PUBLIC(QQuickView) diff --git a/tests/benchmarks/qml/qmltime/qmltime.cpp b/tests/benchmarks/qml/qmltime/qmltime.cpp index bd8477164a..2abe71fb4c 100644 --- a/tests/benchmarks/qml/qmltime/qmltime.cpp +++ b/tests/benchmarks/qml/qmltime/qmltime.cpp @@ -33,11 +33,13 @@ #include #include #include -#include +#include #include #include -#include -#include +#include +#include + +#include class Timer : public QObject { @@ -64,22 +66,22 @@ private: static Timer *m_timer; bool m_willparent; - QGraphicsScene m_scene; - QGraphicsRectItem m_item; + QQuickView m_view; + QQuickItem *m_item; }; QML_DECLARE_TYPE(Timer); Timer *Timer::m_timer = 0; Timer::Timer() -: m_component(0), m_willparent(false) + : m_component(0) + , m_willparent(false) + , m_item(new QQuickItem) { if (m_timer) qWarning("Timer: Timer already registered"); + QQuickViewPrivate::get(&m_view)->setRootObject(m_item); m_timer = this; - - m_scene.setItemIndexMethod(QGraphicsScene::NoIndex); - m_scene.addItem(&m_item); } QQmlComponent *Timer::component() const @@ -102,9 +104,9 @@ void Timer::run(uint iterations) QQmlContext context(qmlContext(this)); QObject *o = m_component->create(&context); - QGraphicsObject *go = qobject_cast(o); - if (m_willparent && go) - go->setParentItem(&m_item); + QQuickItem *i = qobject_cast(o); + if (m_willparent && i) + i->setParentItem(m_item); delete o; runTest(&context, iterations); @@ -126,9 +128,9 @@ void Timer::runTest(QQmlContext *context, uint iterations) t.start(); for (uint ii = 0; ii < iterations; ++ii) { QObject *o = m_component->create(context); - QGraphicsObject *go = qobject_cast(o); - if (m_willparent && go) - go->setParentItem(&m_item); + QQuickItem *i = qobject_cast(o); + if (m_willparent && i) + i->setParentItem(m_item); delete o; } @@ -207,7 +209,7 @@ void usage(const char *name) int main(int argc, char ** argv) { - QApplication app(argc, argv); + QGuiApplication app(argc, argv); qmlRegisterType("QmlTime", 1, 0, "Timer"); diff --git a/tests/benchmarks/qml/qmltime/qmltime.pro b/tests/benchmarks/qml/qmltime/qmltime.pro index 4e3e9471a4..fa93e91af0 100644 --- a/tests/benchmarks/qml/qmltime/qmltime.pro +++ b/tests/benchmarks/qml/qmltime/qmltime.pro @@ -1,7 +1,8 @@ CONFIG += testcase TEMPLATE = app TARGET = qmltime -QT += qml widgets testlib +QT += qml testlib quick +QT += quick-private macx:CONFIG -= app_bundle SOURCES += qmltime.cpp -- cgit v1.2.3