[Interest] React to signal only when at top of StackView
Elvis Stansvik
elvstone at gmail.com
Fri May 6 22:27:44 CEST 2016
Hi all,
I want that an item reacts to a certain signal only when it is at the
top of a StackView, so I tried something like:
Connections {
// Below won't work:
target: Stack.status === Stack.Active ? button : null
//target: button // ..but this works
onClicked: console.log("clicked")
}
That is, making the target of the connection null unless Stack.status
== Stack.Active, but it seems it's not working.
Full example below:
import QtQuick 2.4
import QtQuick.Controls 1.3
import QtQuick.Window 2.2
Window {
id: window
width: 500
height: 500
visible: true
Column {
Rectangle {
width: 100
height: 100
color: "gray"
MouseArea {
id: button
anchors.fill: parent
Text {
text: "Click Me"
anchors.centerIn: parent
}
}
}
StackView {
id: stackView
width: 100
height: 100
initialItem: Rectangle {
anchors.fill: parent
color: "green"
Connections {
// Below won't work:
target: Stack.status === Stack.Active ? button : null
//target: button // ..but this works
onClicked: console.log("clicked")
}
}
}
}
}
Anyone know what the problem might be? The item here is definitely
active on the stack, since it's the initial (and only item).
Cheers,
Elvis
More information about the Interest
mailing list