diff options
author | Robin Burchell <[email protected]> | 2015-01-06 19:29:08 +0100 |
---|---|---|
committer | Robin Burchell <[email protected]> | 2016-03-11 14:42:46 +0000 |
commit | 4c065b497e63832cf610cc06d67a7b40965154fb (patch) | |
tree | d339ef743be8c9bc1412cfa4560691d35381d8c1 | |
parent | a05f3ee00c903c5fa5965187c72dae04f960e2e4 (diff) |
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 <[email protected]>
Reviewed-by: Shawn Rutledge <[email protected]>
Reviewed-by: Michael Brasser <[email protected]>
-rw-r--r-- | src/quick/items/qquickview_p.h | 2 | ||||
-rw-r--r-- | tests/benchmarks/qml/qmltime/qmltime.cpp | 34 | ||||
-rw-r--r-- | 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 <QQmlEngine> #include <QQmlComponent> #include <QDebug> -#include <QApplication> +#include <QGuiApplication> #include <QTime> #include <QQmlContext> -#include <QGraphicsScene> -#include <QGraphicsRectItem> +#include <QQuickView> +#include <QQuickItem> + +#include <private/qquickview_p.h> 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<QGraphicsObject *>(o); - if (m_willparent && go) - go->setParentItem(&m_item); + QQuickItem *i = qobject_cast<QQuickItem *>(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<QGraphicsObject *>(o); - if (m_willparent && go) - go->setParentItem(&m_item); + QQuickItem *i = qobject_cast<QQuickItem *>(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<Timer>("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 |