From 2f3b4ec528f48747a3b7e91e9a7254c25ce24c99 Mon Sep 17 00:00:00 2001 From: Fabian Kosmale Date: Thu, 5 Sep 2019 13:03:59 +0200 Subject: Introduce required properties to QML [ChangeLog][QtQml] "required" is now a (contextual) keyword in QML, and users can mark properties with it to specify that those properties must be set when the component gets instantiated. This can be done either declaratively via standard property bindings from QML, or imperatively by using the functions to set initial properties (QQmlCompoent::setInitalProperties and related functions in C++, Qt.createObject, Loader.setSource,... in QML/JS). Logic has been added to QQmlComponent::create and the various QQmlIncubator classes to verify that the required properties were set. If properties marked as required are not set, a warning will be printed at runtime, and the component will not be created. Change-Id: I8e38227fc8f173b053b689c1597dc7fd40e835e7 Reviewed-by: Ulf Hermann Reviewed-by: Simon Hausmann --- src/qml/compiler/qqmlirbuilder.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/qml/compiler') diff --git a/src/qml/compiler/qqmlirbuilder.cpp b/src/qml/compiler/qqmlirbuilder.cpp index afe68b72cb..fbb6a07b1b 100644 --- a/src/qml/compiler/qqmlirbuilder.cpp +++ b/src/qml/compiler/qqmlirbuilder.cpp @@ -847,6 +847,7 @@ bool IRBuilder::visit(QQmlJS::AST::UiPublicMember *node) Property *property = New(); property->isReadOnly = node->isReadonlyMember; + property->isRequired = node->isRequired; QV4::CompiledData::BuiltinType builtinPropertyType = Parameter::stringToBuiltinType(memberType); bool typeFound = builtinPropertyType != QV4::CompiledData::BuiltinType::InvalidBuiltin; -- cgit v1.2.3