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 alias an array based property in qml?
Forum Updated to NodeBB v4.3 + New Features

How to alias an array based property in qml?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 694 Views
  • 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.
  • J Offline
    J Offline
    JennyAug13
    wrote on last edited by
    #1

    I have property called

    property var playerControls: [
            playerControl1,
            playerControl2
        ]
    
    

    How can i alias an array based property and use in a for loop in other qml file iterating between my playerControls. Thanks in advance.

    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      Did you try defining the alias ? What is the difficulty you faced ? You can check this.

      Window {
          visible: true
          width: 440
          height: 480
          title: qsTr("http://www.pthinks.com")
          property alias jennyList: r1.mylist
          Rectangle{
              id : r1
              anchors.fill: parent;color :"blue"
              property var mylist :["dheeru","guru","Shreepoorna"]
          }
          MouseArea{
              anchors.fill: parent
              onClicked: {
                  for(var i=0;i<jennyList.length;i++){
                      console.log(jennyList[i])
                  }
              }
          }
      }
      

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

      1 Reply Last reply
      1
      • J Offline
        J Offline
        JennyAug13
        wrote on last edited by
        #3

        Yes, i have an array based access to playerControl instances inside my qml file as follows.

        property var playerControls: [
                playerControl1,
                playerControl2
            ]
        

        I have to make an alias to the above property which will also be same as the above list so that i can use them as follows in the top level qml files with the above component inside.

         Component {
        
                id: chControlComponent
        
                multiControl {
        
                    id: mrc
        
                   playerControl1.visible: true
        
                   playerControl2.visible: true
                   ...
                   ...
                   ...
        }
        
        1 Reply Last reply
        0

        • Login

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