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 Remove an item from Column Element
Forum Updated to NodeBB v4.3 + New Features

How to Remove an item from Column Element

Scheduled Pinned Locked Moved Solved QML and Qt Quick
qtquick2qmlqtquickqtquick.controlcolumn
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.
  • P Offline
    P Offline
    pra7
    wrote on last edited by pra7
    #1

    I want to remove some controls which are created in Column QML type and also how to access the children? .Following is the code:

    import QtQuick 2.6
    import QtQuick.controls 2.2
    
    Item
    {
    Column {
        id:col
        spacing: 2
    
        Rectangle { color: "red"; width: 50; height: 50 }
        Rectangle { color: "green"; width: 20; height: 50 }
        Rectangle { color: "blue"; width: 50; height: 20 }
    }
    
    Button
    {
        id:button
        onClicked: 
        {
            //How to remove perticular element from above column ?
        }
    
       }
    }
    
    E 1 Reply Last reply
    0
    • E Eeli K

      @pra7 You could (again) try the Repeater/model approach. Repeater is inside the column, Rectangle is the delegate and the model has color, width and height. Then change the model (ListModel) dynamically.

      P Offline
      P Offline
      pra7
      wrote on last edited by
      #3

      @Eeli-K Thanks for the suggestion it worked and also there is another approach "Component.CreateObject()" in which we can create and destroy objects dynamically.

      1 Reply Last reply
      1
      • P pra7

        I want to remove some controls which are created in Column QML type and also how to access the children? .Following is the code:

        import QtQuick 2.6
        import QtQuick.controls 2.2
        
        Item
        {
        Column {
            id:col
            spacing: 2
        
            Rectangle { color: "red"; width: 50; height: 50 }
            Rectangle { color: "green"; width: 20; height: 50 }
            Rectangle { color: "blue"; width: 50; height: 20 }
        }
        
        Button
        {
            id:button
            onClicked: 
            {
                //How to remove perticular element from above column ?
            }
        
           }
        }
        
        E Offline
        E Offline
        Eeli K
        wrote on last edited by
        #2

        @pra7 You could (again) try the Repeater/model approach. Repeater is inside the column, Rectangle is the delegate and the model has color, width and height. Then change the model (ListModel) dynamically.

        P 1 Reply Last reply
        1
        • E Eeli K

          @pra7 You could (again) try the Repeater/model approach. Repeater is inside the column, Rectangle is the delegate and the model has color, width and height. Then change the model (ListModel) dynamically.

          P Offline
          P Offline
          pra7
          wrote on last edited by
          #3

          @Eeli-K Thanks for the suggestion it worked and also there is another approach "Component.CreateObject()" in which we can create and destroy objects dynamically.

          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