aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquickview.cpp
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@digia.com>2012-11-05 11:04:21 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2012-11-05 18:09:26 +0100
commita3220e460bdcb9bc878bfe37721a7798ac8c2d64 (patch)
treed7549624410ebde94c920314c4d5d80f3dbef0d8 /src/quick/items/qquickview.cpp
parent0b019fcc52560d0a7016f733cb2bea3e03893ec0 (diff)
qmlscene can start with either an Item or Window as the qml root
Before, it assumed that the root is an Item and needs to have a Window created. But it's useful for an application to have a Window as the root, and it was already possible by writing a different C++ main function (see qtdeclarative/examples/window/window/window.cpp). It doesn't take much to give qmlscene this flexibility too. Change-Id: Ie808e78a42074e13aa9d3c87723ec9ac8fdbaf4a Reviewed-by: Samuel Rødal <samuel.rodal@digia.com>
Diffstat (limited to 'src/quick/items/qquickview.cpp')
-rw-r--r--src/quick/items/qquickview.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/quick/items/qquickview.cpp b/src/quick/items/qquickview.cpp
index 7182e74c0c..befba37515 100644
--- a/src/quick/items/qquickview.cpp
+++ b/src/quick/items/qquickview.cpp
@@ -236,6 +236,31 @@ void QQuickView::setSource(const QUrl& url)
}
/*!
+ \internal
+
+ Set the source \a url, \a component and content \a item (root of the QML object hierarchy) directly.
+ */
+void QQuickView::setContent(const QUrl& url, QQmlComponent *component, QObject* item)
+{
+ Q_D(QQuickView);
+ d->source = url;
+ d->component = component;
+
+ if (d->component && d->component->isError()) {
+ QList<QQmlError> errorList = d->component->errors();
+ foreach (const QQmlError &error, errorList) {
+ QMessageLogger(error.url().toString().toLatin1().constData(), error.line(), 0).warning()
+ << error;
+ }
+ emit statusChanged(status());
+ return;
+ }
+
+ d->setRootObject(item);
+ emit statusChanged(status());
+}
+
+/*!
Returns the source URL, if set.
\sa setSource()