diff options
author | Robin Burchell <robin.burchell@viroteck.net> | 2015-01-06 19:29:08 +0100 |
---|---|---|
committer | Robin Burchell <robin.burchell@viroteck.net> | 2016-03-11 14:42:46 +0000 |
commit | 4c065b497e63832cf610cc06d67a7b40965154fb (patch) | |
tree | d339ef743be8c9bc1412cfa4560691d35381d8c1 /tests/benchmarks/qml/qmltime/qmltime.cpp | |
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 <simon.hausmann@theqtcompany.com>
Reviewed-by: Shawn Rutledge <shawn.rutledge@theqtcompany.com>
Reviewed-by: Michael Brasser <michael.brasser@live.com>
Diffstat (limited to 'tests/benchmarks/qml/qmltime/qmltime.cpp')
-rw-r--r-- | tests/benchmarks/qml/qmltime/qmltime.cpp | 34 |
1 files changed, 18 insertions, 16 deletions
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"); |