Details
-
Suggestion
-
Resolution: Out of scope
-
P3: Somewhat important
-
6.2.0, 6.3.0
Description
Qt 6.2 has a nice addition being able use optional chaining operator in QML bindings:
Item { property Item item visible: item?.someBooleanProperty }
This kind of a use scenario is common from my experience with our large QML app.
However, that could be made simpler, by allowing setting 'undefined' as false to boolean properties. Now this causes "Error: Cannot assign [undefined] to bool" and if the assignment is done in a function call instead of in a binding, the error may cause important code to be skipped. It's tedious and easy to forget to convert it to boolean in every use case:
visible: Boolean(item?.someBooleanProperty)
or
visible: !!(item?.someBooleanProperty)
or
visible: item?.someBooleanProperty ?? false
Probably you can yourself register a converter from undefined to boolean properties in your app, but I think this should be enabled by default. What do you think?
Attachments
Issue Links
- is replaced by
-
QTBUG-119966 qmllint:Warn about (potential) undefined assigment
- Reported