-
Suggestion
-
Resolution: Unresolved
-
P2: Important
-
None
Consider different ways we could (accidentally) shove incompatible types into strongly-typed properties.
Code
import QtQuick Window { id: window width: 400 height: 300 visible: true property Item itemProp: window // Runtime + qmlsc + qmllint + qmlls warnings property list<Item> itemList: [ window // Runtime warning only ] function assignItemProp() { window.itemProp = window // Runtime + qmlsc warnings only } function assignItemList() { window.itemList[0] = window // Runtime + qmlsc warnings only } Component.onCompleted: { assignItemProp() assignItemList() } }
Outcomes
We get a mixed bag of warnings:
Incompatible assignment | Runtime warning | qmllint/qmlls warning | qmlsc warning |
---|---|---|---|
itemProp declarative initialization | ✔️ | ✔️ | ✔️ |
itemList declarative initialization | ✔️ | ❌ | ❌ |
itemProp imperative assignment | ✔️ | ❌ | ✔️ |
itemList imperative assignment | ✔️ | ❌ | ✔️ |
Suggestion
Fill the table above with ticks, if all types involved are known at edit/build time.
Use case
A customer upgraded to Qt 6.8 and they now see new incompatible-type warnings across their project (thanks to the fix for QTBUG-127343), like:
qt.qml.list.incompatible: Cannot append Main_QMLTYPE_0(0x26857677a50) to a QML list of QQuickItem*
However, there is no easy way to track down (and fix) the cause of these warnings.
- relates to
-
QTBUG-127583 QML tools: Detect and warn about potential naming errors in QML Connections
-
- Reported
-
-
QTBUG-139735 qmlsc: Fill in missing values in warnings about incompatible types
-
- Reported
-
- split from
-
QTBUG-127343 Incomplete and inconsistent type checking for QML lists
-
- Closed
-