StackView pop doesn't destroy the items



  • Here my code so far:

    import QtQuick 2.9
    import QtQuick.Controls 1.0
    
    Rectangle {
        id: root
        visible: true
        width: 1280
        height: 1024
        color: "transparent"
    
        Component.onCompleted: {
            stackView.push({ item: pageIN01, destroyOnPop: true })
        }
    
        StackView {
            id: stackView
            anchors.fill: parent
    
            delegate: StackViewDelegate {
                    function transitionFinished(properties) {
                        properties.exitItem.opacity = 1
                    }
    
                    pushTransition: StackViewTransition {
                        PropertyAnimation {
                            target: enterItem
                            property: "opacity"
                            duration: 600
                            from: 0
                            to: 1
                        }
    
                        PropertyAnimation {
                            target: exitItem
                            property: "opacity"
                            duration: 600
                            from: 1
                            to: 0
                        }
                    }
                }
        }
    
        Component {
            id: pageIN01
            IN01 {
                Timer {
                    interval: 3000
                    running: true
                    repeat: false
                    onTriggered: {
                        stackView.push(pageIN02)
                    }
                }
            }
        }
    
        Component {
            id: pageIN02
            IN02 {
                onScenarioSelected: {
                    stackView.push({ item: pageSC00, destroyOnPop: true })
                }
            }
        }
    
        Component {
            id: pageSC00
            SC00 {
                onBack: {
                    stackView.pop({immediate: true})
                }
            }
        }
    

    Having set the destroyOnPop property to true I'm expecting the item is actually destroyed on pop.
    Instead I notice that they are still alice. For example I have some signals connected from C++ to QML:

    pageSC00:

        Component.onCompleted: {
            MyApp.currentItemChanged.connect(currentItemChanged)
        }
    
        function currentItemChanged()
        {
            console.log("triggered!")
        }
    

    The actual behavior is the following:

    1. pageIN01 is pushed on the stack
    2. after 3 seconds pageIN02 is pushed on the stack
    3. until now, the currentItemChanged() is never catch
    4. when the used do something that triggers the signal onScenarioSelected() pageSC00 is pushed on the stack
    5. now, as expected, the currentItemChanged() is catch
    6. when the signal onBack() is emitted, pageSC00 is popped (and I wish destroyed too) but unfortunately the currentItemChanged() is still catch from pageSC00!

    Why it's not destroyed on pop?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.