Access function/slot loader element in listview
-
Hello,
I would like to know if it's possible to call a function in component loaded in listview.
Let me explain :I have a main.qml file with a Lisview to display my application pages :
//main.qml ListView { id:myListView anchors.fill: parent orientation: ListView.Horizontal cacheBuffer: main.width * (NbPages-1) model: PageNames delegate: Loader { id: myLoader source: modelData + ".qml" } }
And in every item of "modelData " I have a function called "cyclicActions"
//page1.qml function cyclicActions() { ---- } //page2.qml function cyclicActions() { ---- }
So I want to call cyclicActions only for the currentItem of the Listview.
I saw ListView.currentItem method but I can't access to the function.Can you help me with that ?
Than you
-
@Delta_sim said in Access function/slot loader element in listview:
I saw ListView.currentItem method but I can't access to the function.
How did you try to access it?
In general, something like this might work:
// Some JS block: myListView.currentItem.item.cyclicActions()
-
@Delta_sim said in Access function/slot loader element in listview:
I saw ListView.currentItem method but I can't access to the function.
as @sierdzio said.
If you call your method onlistView.currentItem
directly you are actually calling it on the Loader item -