diff options
-rw-r--r-- | src/quick/doc/snippets/qquickview-ex.cpp | 9 | ||||
-rw-r--r-- | src/quick/items/qquickview.cpp | 4 |
2 files changed, 13 insertions, 0 deletions
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<QQuickView> 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 |