Details
-
Bug
-
Resolution: Fixed
-
P2: Important
-
Qt for MCUs 2.6
-
None
-
453db521, 71c8ffad, 2a0ad1d5
Description
there's something called required property in big qt(https://doc.qt.io/qt-6/qtqml-syntax-objectattributes.html#required-properties).
one of the effects of the required property mentioned in the doc above is that the qml file instanciating a custom qml type with a required property must initialize that required property, otherwise an error occurs.
however in qt for mcus, the behavior seems to differ.
with the code below:
// MyComponent.qml import QtQuick Text { required property int a Item { } } // RequiredExperiment.qml <-- main qml file import QtQuick Rectangle { MyComponent { anchors.centerIn: parent text: "Qt for MCUs" } }
i got this error:
C:/Users/81808/Downloads/RequiredExperiment/MyComponent.qml:4:5: error: Required property outside of a delegate
required property int a
this is yelling at me as the required property is not inside delegate, but in big qt, this syntax should be allowed.
here is the code with big qt 6.6:
// MyComponent.qml import QtQuick import QtQuick.Window Text { required property int a Item { } } // RequiredExperimentBigQt.qml <-- main qml file import QtQuick import QtQuick.Window Window { width: 640 height: 480 visible: true title: qsTr("Hello World") MyComponent { } }
the build didn't emit an error but i got a runtime error:
11:55:40: Starting C:\Users\81808\Downloads\build-RequiredExperimentBigQt-Desktop_Qt_6_6_0_MinGW_64_bit-Debug\appRequiredExperimentBigQt.exe...
QQmlApplicationEngine failed to create component
qrc:/RequiredExperimentBigQt/MyComponent.qml:5:5: Required property a was not initialized
QML debugging is enabled. Only use this in a safe environment.
by the way, even when i initialized the required property like this in the mcu project:
import QtQuick Rectangle { MyComponent { a: 1 // <--- initialize it anchors.centerIn: parent text: "Qt for MCUs" } }
i got this error:
C:/Users/81808/Downloads/RequiredExperiment/RequiredExperiment.qml:5:9: error: Binding on read-only property a: 1
i've checked the known issues and limitations of 2.6 but couldn't find this issue.
https://doc.qt.io/QtForMCUs-2.6/qtul-known-issues.html
both projects are attached to this ticket.
Attachments
Issue Links
- mentioned in
-
Page Loading...