Using "parent->findChild<QObject*>("objectName")"function,return null,when I find a ItemDelegate QML
Unsolved
QML and Qt Quick
-
ListView { id: listView objectName: "mainListView" currentIndex: -1 anchors.fill: parent anchors.top: parent.Top anchors.topMargin: 0.22*parent.height delegate: ItemDelegate { id: mainItemDelegate objectName: "mainItemDelegate" width: parent.width anchors.horizontalCenter: parent.horizontalCenter Image { width: 0.1*parent.width height: 0.8*parent.height anchors.left: parent.left anchors.leftMargin: 0.1*parent.width source: model.icon } Label { width: 0.5*parent.width height: parent.height text: model.title anchors.horizontalCenter: parent.horizontalCenter } highlighted: ListView.isCurrentItem onClicked: { if (listView.currentIndex != index) { listView.currentIndex = index mainStackView.replace(model.source) if(2==index) { mainMenu.drawerItemChanged(index) // toolBarTop.visible = fasle } } mainDrawer.close() } }
This is my code in QML.
-
ListView { id: listView objectName: "mainListView" currentIndex: -1 anchors.fill: parent anchors.top: parent.Top anchors.topMargin: 0.22*parent.height delegate: ItemDelegate { id: mainItemDelegate objectName: "mainItemDelegate" width: parent.width anchors.horizontalCenter: parent.horizontalCenter Image { width: 0.1*parent.width height: 0.8*parent.height anchors.left: parent.left anchors.leftMargin: 0.1*parent.width source: model.icon } Label { width: 0.5*parent.width height: parent.height text: model.title anchors.horizontalCenter: parent.horizontalCenter } highlighted: ListView.isCurrentItem onClicked: { if (listView.currentIndex != index) { listView.currentIndex = index mainStackView.replace(model.source) if(2==index) { mainMenu.drawerItemChanged(index) // toolBarTop.visible = fasle } } mainDrawer.close() } }
This is my code in QML.
@Daryl_X Refer the link which explains your query.
https://forum.qt.io/topic/7401/problem-with-finding-qml-elements-placed-within-listview-s-delegate-from-c-code-resolved/5 -
@Daryl_X Refer the link which explains your query.
https://forum.qt.io/topic/7401/problem-with-finding-qml-elements-placed-within-listview-s-delegate-from-c-code-resolved/5@Arvindhan-Ponnusamy I run the code run time,but still.