[Solved] Dynamic sourceComponent of Loader and changing property of components
-
You're Welcome :)
There's a topic combobox at the bottom. It has the "Mark Solved" option. -
wrote on 9 Mar 2015, 04:30 last edited by
By the way, if I want to change the properties of the components loaded by the loader out of the Loader block, how can that be done? As I understand there is no id of the instances of the components.
-
By the way, if I want to change the properties of the components loaded by the loader out of the Loader block, how can that be done? As I understand there is no id of the instances of the components.
@myQtQml in the same way as earlier. Loader would be accessible outside too.
-
wrote on 9 Mar 2015, 05:57 last edited by
item is the present item being loaded. loader.item.text would give text of which component? There are 4 components loaded by the loader in the above example.
-
Ok understood, so in that case to access delegates from outside ListView, you will need to use children or you can set an item as current item and then access it
listview.currentIndex=1 // 1 is index of delegate, listview = id of ListView console.log(listview.currentItem)
-
wrote on 9 Mar 2015, 10:57 last edited by
I have added the following code to access text of the components
Button { width: 100; height: 40; text: "Get Text"; anchors.top: listView.bottom onClicked: { listView.currentIndex = 2 // or anything else (0 - 3) console.log(listView.currentIndex, listView.currentItem.text) } }
The output (listView.currentItem.text) is alway undefined for any value of listView.currentIndex. Am I doing anything wrong?
-
Ok. Now you have to go further. The currentItem will be the Loader. Try getting children of it
console.log(listView.currentIndex, listView.currentItem.children)
and then try accessing the childrens. It is an array.
-
wrote on 10 Mar 2015, 03:35 last edited by myQtQml 3 Oct 2015, 03:37
Working. Thanks again. I don't see any "Mark Solved" option in Topic Tools combobox.
-
Well I do see it. Its the bottom entry in the combobox . I'll mark it as solved.
-
Strange I'm to not able to mark it as solved. Clicking doesn't have any effect.
13/13