Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved How to Remove an item from Column Element

    QML and Qt Quick
    qtquick2 qml qtquick qtquick.control column
    2
    3
    1114
    Loading More Posts
    • 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
      pra7 last edited by 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 1 Reply Last reply Reply Quote 0
      • P
        pra7 @Eeli K last edited by

        @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 Reply Quote 1
        • E
          Eeli K @pra7 last edited by

          @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 Reply Quote 1
          • P
            pra7 @Eeli K last edited by

            @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 Reply Quote 1
            • First post
              Last post