Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to access the loader element defined in listview

How to access the loader element defined in listview

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 3 Posters 298 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Praveen.Illa
    wrote on last edited by
    #1

    Hi Team,

    How can I get the access to the loader element defined in listview.
    Please find the sample code below

    Rectangle {
    	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" 
    			}
    		}	
    	}
    }
    
    dheerendraD 1 Reply Last reply
    0
    • P Praveen.Illa

      Hi Team,

      How can I get the access to the loader element defined in listview.
      Please find the sample code below

      Rectangle {
      	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" 
      			}
      		}	
      	}
      }
      
      dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      @Praveen-Illa

      Not possible. Not a good way also as delegate objects may get deleted.

      Dheerendra
      @Community Service
      Certified Qt Specialist
      http://www.pthinks.com

      1 Reply Last reply
      0
      • Marko StankeM Offline
        Marko StankeM Offline
        Marko Stanke
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved