Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

delete Item and load another on the same ApplicationWindow



  • Hey,
    I have this Application which shows an Item and on ButtonClick it loads another qml file.

    My Question is how do I close/delete "rootItem" instead of only set

    rootItem.visible = false
    

    because I dont need it anymore after the Button is clicked.

    ApplicationWindow  {
            id: mainWindow
            .....
    
            Item {
               id: rootItem
             .....
               Button {
                   id: okButton
                   text: "OK"
                   onClicked: { coreApp.receiveOkButtonClick() }
               }
            }
    
           Connection{
                target: coreApp
    
                onLoadPage: {
                   var component
                   var connectionPage
                   component = Qt.createComponent( "qrc:/Page.qml" )
                   rootItem.visible = false
                   connectionPage = component.createObject( mainWindow )
           
                   }
            }
    }
    

Log in to reply