From 54d4f8f526f9c9a1af702b14925e1d34ee8b2134 Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Thu, 12 Nov 2020 12:11:29 +0100 Subject: QQuickView docs: show correct usage of setInitialProperties Pick-to: 5.15 Change-Id: If63f4c59f18bc0754ce2e68e424f6efd0f512d30 Reviewed-by: Mitch Curtis --- src/quick/doc/snippets/qquickview-ex.cpp | 9 +++++++++ src/quick/items/qquickview.cpp | 4 ++++ 2 files changed, 13 insertions(+) (limited to 'src') diff --git a/src/quick/doc/snippets/qquickview-ex.cpp b/src/quick/doc/snippets/qquickview-ex.cpp index 32406f8f2f..5f93dfdbe8 100644 --- a/src/quick/doc/snippets/qquickview-ex.cpp +++ b/src/quick/doc/snippets/qquickview-ex.cpp @@ -59,3 +59,12 @@ int main(int argc, char *argv[]) return app.exec(); } //![0] + +void makeDocTeamHappyByKeepingExampleCompilable() { +//![1] + QScopedPointer view { new QQuickView }; + view->setInitialProperties({"x, 100"}, {"width", 50}); + view->setSource(QUrl::fromLocalFile("myqmlfile.qml")); + view->show(); +//![1] +} diff --git a/src/quick/items/qquickview.cpp b/src/quick/items/qquickview.cpp index 97f6689d8a..b3a5270e9b 100644 --- a/src/quick/items/qquickview.cpp +++ b/src/quick/items/qquickview.cpp @@ -240,7 +240,11 @@ void QQuickView::setSource(const QUrl& url) Sets the initial properties \a initialProperties with which the QML component gets initialized after calling \l QQuickView::setSource(). + \snippet qquickview-ex.cpp 1 + \note You can only use this function to initialize top-level properties. + \note This function should always be called before setSource, as it has + no effect once the component has become \c Ready. \sa QQmlComponent::createWithInitialProperties() \since 5.14 -- cgit v1.2.3