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 can i delete a rectangle (without using visible property)

How can i delete a rectangle (without using visible property)

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

    Hi guys
    I want to delete rect_one when I click on rect_two and I don't have to use visible property.

    code:

    import QtQuick 2.9
    import QtQuick.Window 2.2
    
    Window {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
    
        Rectangle
        {
    
            id: rect_one
            color:"RED"
            height:100
            width:100
    
        }
    
        Rectangle
        {
            id:rect_two
            color:"Blue"
            height:100
            width:100
            x:300
            MouseArea
            {
                anchors.fill:parent
                onClicked:{//Here what should i write to delete rect_one and i dont want to use visible property}
                }
    
            }
        }
    
    }
    

    What is the way to do this?

    Thanks
    Ashish Ajgaonkar

    ODБOïO 1 Reply Last reply
    0
    • ashajgA ashajg

      Hi guys
      I want to delete rect_one when I click on rect_two and I don't have to use visible property.

      code:

      import QtQuick 2.9
      import QtQuick.Window 2.2
      
      Window {
          visible: true
          width: 640
          height: 480
          title: qsTr("Hello World")
      
          Rectangle
          {
      
              id: rect_one
              color:"RED"
              height:100
              width:100
      
          }
      
          Rectangle
          {
              id:rect_two
              color:"Blue"
              height:100
              width:100
              x:300
              MouseArea
              {
                  anchors.fill:parent
                  onClicked:{//Here what should i write to delete rect_one and i dont want to use visible property}
                  }
      
              }
          }
      
      }
      

      What is the way to do this?

      Thanks
      Ashish Ajgaonkar

      ODБOïO Offline
      ODБOïO Offline
      ODБOï
      wrote on last edited by ODБOï
      #2

      @ashajg hi you can call

      destroy()
      

      but doc states you should avoid deleting objects that you did not dynamically create yourself

      see also opacity

      ashajgA 1 Reply Last reply
      3
      • ODБOïO ODБOï

        @ashajg hi you can call

        destroy()
        

        but doc states you should avoid deleting objects that you did not dynamically create yourself

        see also opacity

        ashajgA Offline
        ashajgA Offline
        ashajg
        wrote on last edited by ashajg
        #3

        hi @LeLev

        Thank you it worked!!!!

        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