Details
-
Bug
-
Resolution: Fixed
-
P1: Critical
-
6.2.10, 6.5.3, 6.6.0
-
1f551faa0 (dev)
Description
It can reproduce by running the code below.
import QtQuick import QtQuick.Window Window { width: 640 height: 480 visible: true title: qsTr("Hello World") component InlineListItem: Text { required property string name height: 50 text: name } Row{ id :row property InlineListItem name1: InlineListItem{name: "value"} } Text { id:text property string name: "value" text: name height:50 } MyText{ id: mytest name:"value" } Item { id:item1 property int parentColor: (row.name1 as InlineListItem)?"1": "0" } Item { id:item2 property int parentColor: (text as Text )?"2": "0" } Item { id:item3 property int parentColor: (mytest as MyText )?"3": "0" } Rectangle { id:rect2 width: 100 height:100 anchors.centerIn: parent color: "yellow" MouseArea{ id:mouse1 width: 100 anchors.fill: parent onClicked: { console.log(item1.parentColor) console.log(item2.parentColor) console.log(item3.parentColor) } } } }
notes:
There are three conditions which cover inline component, normal component, the component declared in another file(attached MyText.qml). hit the yellow rectangle to see output of console.
expecting outcome
the console output should be
1
2
3
which means all component can cast successfully.
real outcome
the console output is
0
2
3
Attachments
Issue Links
- is duplicated by
-
QTBUG-116264 Inline component not recognized as a type with "... as Type"
-
- Closed
-
-
QTBUG-120553 Javascript "as casting" doesn't work with inline components
-
- Closed
-
For Gerrit Dashboard: QTBUG-118431 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
516399,2 | QML: Test as-casting to inline component | dev | qt/qtdeclarative | Status: MERGED | +2 | 0 |