aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Kudryavtsev <a.kudryavtsev@netris.ru>2016-10-10 15:03:01 +0300
committerAnton Kudryavtsev <a.kudryavtsev@netris.ru>2016-10-13 17:12:16 +0000
commit2fecb343c2812d2f7e0fe705074401f3fb152279 (patch)
treefdcb2c7f0d9a7c1d0f1657cf0e64da8f990af30c
parenteff37a46ce33078f6f601bd724bbb7359b5db055 (diff)
QQmlApplicationEngine: mark rootObjects() as const
This method does not modify the object. Can't change the API, so overload and mark the old function for removal in Qt 6. Change-Id: I15943c770b30460f8ccd14239526e2249c59a242 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
-rw-r--r--src/qml/qml/qqmlapplicationengine.cpp17
-rw-r--r--src/qml/qml/qqmlapplicationengine.h6
2 files changed, 20 insertions, 3 deletions
diff --git a/src/qml/qml/qqmlapplicationengine.cpp b/src/qml/qml/qqmlapplicationengine.cpp
index fef2da753b..1a912d53e6 100644
--- a/src/qml/qml/qqmlapplicationengine.cpp
+++ b/src/qml/qml/qqmlapplicationengine.cpp
@@ -287,14 +287,27 @@ void QQmlApplicationEngine::loadData(const QByteArray &data, const QUrl &url)
Returns a list of all the root objects instantiated by the
QQmlApplicationEngine. This will only contain objects loaded via load() or a
convenience constructor.
+
+ \note In Qt versions prior to 5.9, this function is marked as non-\c{const}.
*/
-QList<QObject *> QQmlApplicationEngine::rootObjects()
+QList<QObject *> QQmlApplicationEngine::rootObjects() const
{
- Q_D(QQmlApplicationEngine);
+ Q_D(const QQmlApplicationEngine);
return d->objects;
}
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+/*!
+ \overload
+ \internal
+*/
+QList<QObject *> QQmlApplicationEngine::rootObjects()
+{
+ return qAsConst(*this).rootObjects();
+}
+#endif // < Qt 6
+
QT_END_NAMESPACE
#include "moc_qqmlapplicationengine.cpp"
diff --git a/src/qml/qml/qqmlapplicationengine.h b/src/qml/qml/qqmlapplicationengine.h
index ff7dce5f8b..e64d7495cd 100644
--- a/src/qml/qml/qqmlapplicationengine.h
+++ b/src/qml/qml/qqmlapplicationengine.h
@@ -58,7 +58,11 @@ public:
QQmlApplicationEngine(const QString &filePath, QObject *parent = Q_NULLPTR);
~QQmlApplicationEngine();
- QList<QObject*> rootObjects();
+#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
+ QList<QObject*> rootObjects(); // ### Qt 6: remove
+#endif
+ QList<QObject*> rootObjects() const;
+
public Q_SLOTS:
void load(const QUrl &url);
void load(const QString &filePath);