How to access the loader element defined in listview
Unsolved
QML and Qt Quick
-
Hi Team,
How can I get the access to the loader element defined in listview.
Please find the sample code belowRectangle { id: rectId property int waveformWidth : parent.width onWaveformWidthChanged: { // How to get access to the loader element at this place ???? console.log("source = ", waveformAreaLoaderId.source) } ListView { id: spo2WaveFormView width: parent.width height: parent.height delegate: Item { id: spo2LayoutItem width: 100 height: 100 Loader { id: waveformAreaLoaderId anchors.fill: parent source: "qrc://main.qml" } } } }
-
Not possible. Not a good way also as delegate objects may get deleted.
-
Directly in that way it's not possible.
What you could do is create an alias inside your delegate item
property alias waveformAreaLoader: waveformAreaLoaderId
and then access it if you know the index of the specific element:
spo2WaveFormView.itemAtIndex(<your index>).waveformAreaLoader.source
Keep in mind if the element is not visible there is a good chance that it's pooled or removed. Which means you will not be able to access it even if you have the index.
A way to avoid is to increase the cacheBuffer to a size where elements will not be destroyed. But it will be a big hit on performance.