StackView pop doesn't destroy the items
Unsolved
QML and Qt Quick
-
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:
- pageIN01 is pushed on the stack
- after 3 seconds pageIN02 is pushed on the stack
- until now, the currentItemChanged() is never catch
- when the used do something that triggers the signal onScenarioSelected() pageSC00 is pushed on the stack
- now, as expected, the currentItemChanged() is catch
- 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?