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. StackView pop doesn't destroy the items
QtWS25 Last Chance

StackView pop doesn't destroy the items

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
1 Posts 1 Posters 580 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.
  • M Offline
    M Offline
    Mark81
    wrote on last edited by Mark81
    #1

    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?

    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