aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/qml/qqmlcomponent.cpp
diff options
context:
space:
mode:
authorTarja Sundqvist <tarja.sundqvist@qt.io>2022-05-16 18:16:38 +0300
committerTarja Sundqvist <tarja.sundqvist@qt.io>2022-05-16 18:16:38 +0300
commitae66ecf0f95c79d730190b92e641c0410d5d6896 (patch)
tree5e5ff0c1f08148a7a421581ba0907314aa90d6a3 /src/qml/qml/qqmlcomponent.cpp
parent04ea6df18a2b06efd133a4f1b13c2e38817279ae (diff)
parent53086eaf2ffb5fc1c360cf13f3d87e8d5f2a7b6f (diff)
Merge remote-tracking branch 'origin/tqtc/lts-5.15.5' into tqtc/lts-5.15-opensourcev5.15.5-lts-lgpl
Diffstat (limited to 'src/qml/qml/qqmlcomponent.cpp')
-rw-r--r--src/qml/qml/qqmlcomponent.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp
index 9ee4fdbe41..c785f8ef51 100644
--- a/src/qml/qml/qqmlcomponent.cpp
+++ b/src/qml/qml/qqmlcomponent.cpp
@@ -375,10 +375,15 @@ bool QQmlComponentPrivate::setInitialProperty(QObject *component, const QString&
{
QQmlProperty prop = QQmlComponentPrivate::removePropertyFromRequired(component, name, requiredProperties());
QQmlPropertyPrivate *privProp = QQmlPropertyPrivate::get(prop);
- if (!prop.isValid() || !privProp->writeValueProperty(value, {})) {
+ const bool isValid = prop.isValid();
+ if (!isValid || !privProp->writeValueProperty(value, {})) {
QQmlError error{};
error.setUrl(url);
- error.setDescription(QLatin1String("Could not set property %1").arg(name));
+ if (isValid)
+ error.setDescription(QLatin1String("Could not set initial property %1").arg(name));
+ else
+ error.setDescription(QLatin1String("Setting initial properties failed: %2 does not have a property called %1").arg(name,
+ QQmlMetaType::prettyTypeName(component)));
state.errors.push_back(error);
return false;
} else
@@ -830,6 +835,14 @@ QObject *QQmlComponent::create(QQmlContext *context)
properties with \a initialProperties. \a context specifies the context
where the object instance is to be created.
+ \omit
+ TODO: also mention errorString() when QTBUG-93239 is fixed
+ \endomit
+
+ If any of the \c initialProperties cannot be set, \l isError() will return
+ \c true, and the \l errors() function can be used to
+ get detailed information about the error(s).
+
\sa QQmlComponent::create
\since 5.14
*/