diff options
author | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2022-05-16 18:16:38 +0300 |
---|---|---|
committer | Tarja Sundqvist <tarja.sundqvist@qt.io> | 2022-05-16 18:16:38 +0300 |
commit | ae66ecf0f95c79d730190b92e641c0410d5d6896 (patch) | |
tree | 5e5ff0c1f08148a7a421581ba0907314aa90d6a3 /src/qml | |
parent | 04ea6df18a2b06efd133a4f1b13c2e38817279ae (diff) | |
parent | 53086eaf2ffb5fc1c360cf13f3d87e8d5f2a7b6f (diff) | |
download | qtdeclarative-ae66ecf0f95c79d730190b92e641c0410d5d6896.tar.gz |
Merge remote-tracking branch 'origin/tqtc/lts-5.15.5' into tqtc/lts-5.15-opensourcev5.15.5-lts-lgpl
Change-Id: I5e0eef69a31bcfda65cf965fb4c8c330581e5168
Diffstat (limited to 'src/qml')
-rw-r--r-- | src/qml/compiler/qqmlirbuilder.cpp | 4 | ||||
-rw-r--r-- | src/qml/doc/src/cppintegration/definetypes.qdoc | 15 | ||||
-rw-r--r-- | src/qml/doc/src/qmlfunctions.qdoc | 10 | ||||
-rw-r--r-- | src/qml/doc/src/qmllanguageref/syntax/signals.qdoc | 2 | ||||
-rw-r--r-- | src/qml/qml/qqmlcomponent.cpp | 17 |
5 files changed, 39 insertions, 9 deletions
diff --git a/src/qml/compiler/qqmlirbuilder.cpp b/src/qml/compiler/qqmlirbuilder.cpp index 89f99e21cd..2ad85ab910 100644 --- a/src/qml/compiler/qqmlirbuilder.cpp +++ b/src/qml/compiler/qqmlirbuilder.cpp @@ -448,7 +448,9 @@ bool IRBuilder::generateFromQml(const QString &code, const QString &url, Documen errors << m; } - return false; + + if (!errors.isEmpty() || !parseResult) + return false; } program = parser.ast(); Q_ASSERT(program); diff --git a/src/qml/doc/src/cppintegration/definetypes.qdoc b/src/qml/doc/src/cppintegration/definetypes.qdoc index ece2fd5fd7..ffe0ec9737 100644 --- a/src/qml/doc/src/cppintegration/definetypes.qdoc +++ b/src/qml/doc/src/cppintegration/definetypes.qdoc @@ -69,6 +69,21 @@ exposed to QML but the type itself should not be instantiable. For a quick guide to choosing the correct approach to expose C++ types to QML, see \l {Choosing the Correct Integration Method Between C++ and QML}. +\section2 Preconditions + +All the macros mentioned below are available from the \c qqml.h +header. You need to add the following code to the files using them in order to +make the macros available: + +\code +#include <QtQml/qqml.h> +\endcode + +Furthermore, your class declarations have to live in headers reachable via your +project's include path. The declarations are used to generate registration code +at compile time, and the registration code needs to include the headers that +contain the declarations. + \section2 Registering an Instantiable Object Type \b{Any QObject-derived C++ class can be registered as the definition of a diff --git a/src/qml/doc/src/qmlfunctions.qdoc b/src/qml/doc/src/qmlfunctions.qdoc index 4e531ceb61..6f5a0c4196 100644 --- a/src/qml/doc/src/qmlfunctions.qdoc +++ b/src/qml/doc/src/qmlfunctions.qdoc @@ -159,11 +159,11 @@ \relates QQmlEngine Declares the enclosing type to be a singleton in QML. This only takes effect - if the type is available in QML, by having a \l QML_ELEMENT or - \l QML_NAMED_ELEMENT() macro. By default, each QQmlEngine will try to create a - singleton instance using the type's default constructor when the type is first - accessed. If there is no default constructor the singleton is initially - inaccessible. This behavior can be overridden by calling + if the type is a \l Q_OBJECT and is available in QML (by having a + \l QML_ELEMENT or \l QML_NAMED_ELEMENT() macro). By default, each QQmlEngine + will try to create a singleton instance using the type's default constructor + when the type is first accessed. If there is no default constructor the + singleton is initially inaccessible. This behavior can be overridden by calling \l qmlRegisterSingletonType() with a specific factory function or \l qmlRegisterSingletonInstance() with a specific instance for the same class and the same type namespace and version. diff --git a/src/qml/doc/src/qmllanguageref/syntax/signals.qdoc b/src/qml/doc/src/qmllanguageref/syntax/signals.qdoc index 075b3a7646..0e06cbec8a 100644 --- a/src/qml/doc/src/qmllanguageref/syntax/signals.qdoc +++ b/src/qml/doc/src/qmllanguageref/syntax/signals.qdoc @@ -133,7 +133,7 @@ Rectangle { Connections { target: button - function onClicked(): { + function onClicked() { rect.color = Qt.rgba(Math.random(), Math.random(), Math.random(), 1); } } 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 */ |