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. Find child out of components and gridlayout in my qml file.
Forum Updated to NodeBB v4.3 + New Features

Find child out of components and gridlayout in my qml file.

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 1.4k 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 my function in player.qml (uppermost qml file) as follows:

    Item {
        id: contractionPlayer
        ....
        ....
        ....
    function passInfoToVisibilityCheck(chIdx, contractionIdx)
        {
            for(var i = 0; i<parent.children.length; i++)
            {
                var child = children[i];
                console.log("var child is ",child);
            }
        }
    
    ...
    ...
    ...
    ...
    ...
    
    Component {
            /*Replacing the channel labels in the previous design with the action buttons for 4 channels*/
            id: chLabelComponent
            actionButton{
                id: chTextButton
                ...
                ...
    
                ```
              }
          Component {
            id: chMultiControlComponent
            multiControl {
                id: mc
            ....
            ....
            ....
        }
    
    GridLayout {
            id: layout
            anchors.fill: parent
            columns:       2
            ....
            ....
            ....
            ....
         }
    
    
    }
    
    Inside my function when I try to find the hildren, i am unable to see the multiControl component with id: mc among them.
    
    How can i expose my component to be sen inside my child variable?
    
    Thanks in advance.
    1 Reply Last reply
    0
    • dheerendraD Offline
      dheerendraD Offline
      dheerendra
      Qt Champions 2022
      wrote on last edited by
      #2

      You have not created the objects of component. Children means objects. Firs crate the object of components.
      What are you trying to achieve ?

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

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

        Yes, now it is working.

        Now my function is as follows:

        function passInfoToBtnVisibilityCheck(chIdx, contractionIdx)
            {
                for (var row = 0; row < 4; row++)
                {
                  for (var col = 1; col < 2; col++)
                  {
                      layout.children[row * layout.columns + col].item.playerControl1.lowerButton.visible = false;
                      layout.children[row * layout.columns + col].item.playerControl1.upperButton.visible = false;
                      layout.children[row * layout.columns + col].item.playerControl2.lowerButton.visible = false;
                      layout.children[row * layout.columns + col].item.playerControl2.upperButton.visible = false;
                  }
                }
            }
        

        I am able to access my

        multiControl component
        

        with playerControls which is a child and also it is inside my gridlayout (with two columns(0 and 1) ) at column 1.

        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