summaryrefslogtreecommitdiffstats
path: root/examples/quick/controls/text/src/main.cpp
diff options
context:
space:
mode:
authorJens Bache-Wiig <jens.bache-wiig@digia.com>2013-05-31 16:07:00 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-06-07 09:39:58 +0200
commit3edcc79bcf9259c77732a8ad15bd8ed6919d4983 (patch)
tree5ab77c88f856d97aa4a6fed5e30a63e0efe7084d /examples/quick/controls/text/src/main.cpp
parenta258188d303f1d3767eda05cd1ce3a96f7541fd8 (diff)
Simplify example code by using QmlApplicationEngine
Since QmlApplicationEngine does all the nasty bits including setting the incubation controller, we should use it in all of our examples. Task-number: QTBUG-31203 Change-Id: Ie4f2313b66ef1a460aa50559f5c0a6125d0c69f1 Reviewed-by: J-P Nurmi <jpnurmi@digia.com> Reviewed-by: Caroline Chao <caroline.chao@digia.com> Reviewed-by: Alan Alpert <aalpert@blackberry.com>
Diffstat (limited to 'examples/quick/controls/text/src/main.cpp')
-rw-r--r--examples/quick/controls/text/src/main.cpp14
1 files changed, 2 insertions, 12 deletions
diff --git a/examples/quick/controls/text/src/main.cpp b/examples/quick/controls/text/src/main.cpp
index 0fc064dce..8d2b8dd07 100644
--- a/examples/quick/controls/text/src/main.cpp
+++ b/examples/quick/controls/text/src/main.cpp
@@ -49,24 +49,14 @@
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
- QQmlEngine engine;
-
qmlRegisterType<DocumentHandler>("org.qtproject.example", 1, 0, "DocumentHandler");
-
- QQmlComponent component(&engine);
- component.loadUrl(QUrl("qrc:/qml/main.qml"));
- if ( !component.isReady() ) {
- qWarning("%s", qPrintable(component.errorString()));
- return -1;
- }
- QObject *topLevel = component.create();
+ QQmlApplicationEngine engine(QUrl("qrc:/qml/main.qml"));
+ QObject *topLevel = engine.rootObjects().value(0);
QQuickWindow *window = qobject_cast<QQuickWindow *>(topLevel);
if ( !window ) {
qWarning("Error: Your root item has to be a Window.");
return -1;
}
-
- QObject::connect(&engine, SIGNAL(quit()), &app, SLOT(quit()));
window->show();
return app.exec();
}