Details
-
Bug
-
Resolution: Fixed
-
P2: Important
-
6.2.0
-
-
bbc8f3ef5ac763cada9b72c53b605e043c771a4c
Description
When using the model/view pattern in QML, a common way of defining a delegate is to define it within a Component:
Component { Text { text: index } }
When an injected property is needed (such as index), this confuses the qmllint tool (which is expected): Property "index" not found on type "Text".
A way to mitigate this and make the QML code more explicit is to define those injected properties as required properties (as per the documented example at https://doc.qt.io/qt-6/qtquick-modelviewsdata-modelview.html ):
Component { id: petdelegate Text { id: label font.pixelSize: 24 text: index === 0 ? type + " (default)" : type required property int index required property string type } }
However, running this code in qmllint brings other warnings:
- Component is missing required property index from here
- Component is missing required property type from here
Given that the Text item is defined within a Component, is it too naive to consider the required properties defined in there will be populated dynamically ?
Is that an expected behavior of qmllint ? If so, is there any other way to comply with it (other than using // qmllint disable) ?
Attachments
Issue Links
- duplicates
-
QTBUG-95373 Component is missing required property index from here
- Closed