diff options
author | Mitch Curtis <mitch.curtis@qt.io> | 2020-04-28 11:41:27 +0200 |
---|---|---|
committer | Mitch Curtis <mitch.curtis@qt.io> | 2020-04-29 12:47:28 +0200 |
commit | 8283d501352fdd0feb5ace1f0d78f30af70ca159 (patch) | |
tree | 7f9126c020021addec598414ea0efb56c6ab527e /src/qml/qml/qqmlapplicationengine.cpp | |
parent | 100ac186a2dcfacc173af340c15f3b942017e7ad (diff) |
Doc: add code example of QQmlApplicationEngine::setInitialProperties()
Show how to use the simpler C++ initializer syntax to create the map.
Pick-to: 5.15
Change-Id: I42b9e8d1be3b45054b1fa8c9f3e026d1e419947a
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qml/qml/qqmlapplicationengine.cpp')
-rw-r--r-- | src/qml/qml/qqmlapplicationengine.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/qml/qml/qqmlapplicationengine.cpp b/src/qml/qml/qqmlapplicationengine.cpp index a2976b59c3..01670b91d3 100644 --- a/src/qml/qml/qqmlapplicationengine.cpp +++ b/src/qml/qml/qqmlapplicationengine.cpp @@ -301,6 +301,17 @@ void QQmlApplicationEngine::load(const QString &filePath) Sets the \a initialProperties with which the QML component gets initialized after it gets loaded. + \code + QQmlApplicationEngine engine; + + EventDatabase eventDatabase; + EventMonitor eventMonitor; + + engine.setInitialProperties({ + { "eventDatabase", QVariant::fromValue(&eventDatabase) }, + { "eventMonitor", QVariant::fromValue(&eventMonitor) } + }); + \endcode \sa QQmlComponent::setInitialProperties \sa QQmlApplicationEngine::load |