Planned maintenance has been done but it did not solve the problem. So work will continue on this and a new time for trying updates will be announced asap.

How to Remove an item from Column Element



  • 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 ?
        }
    
       }
    }


  • @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.



  • @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.



  • @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.