aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items
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
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')
-rw-r--r--src/quick/items/qquickview.cpp25
-rw-r--r--src/quick/items/qquickview.h2
2 files changed, 27 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()
diff --git a/src/quick/items/qquickview.h b/src/quick/items/qquickview.h
index 756890e7ec..4a885bc993 100644
--- a/src/quick/items/qquickview.h
+++ b/src/quick/items/qquickview.h
@@ -54,6 +54,7 @@ class QQmlEngine;
class QQmlContext;
class QQmlError;
class QQuickItem;
+class QQmlComponent;
class QQuickViewPrivate;
class Q_QUICK_EXPORT QQuickView : public QQuickWindow
@@ -90,6 +91,7 @@ public:
public Q_SLOTS:
void setSource(const QUrl&);
+ void setContent(const QUrl& url, QQmlComponent *component, QObject *item);
Q_SIGNALS:
void statusChanged(QQuickView::Status);