I am trying to enable/disable toolbar buttons (any UI state) based on state/function of the active tab.
So say we have a toolbar with a Save (file) button and the first tab reports being able to save a file (or whatever) so the Save button is enabled but switching to the second tab should disable the Save button because it reports not being able to save a file.
This reporting is done with additional properties/functions on the Tab objects themselves in QML.
Implementing the onCurrentIndexChanged on the TabView does give an opportunity to set the initial state of the buttons. But the thing is, the user can -for instance- select something in that 2nd tab that makes it being able to save the file anyway - this should (re)enable the Save button in the toolbar.
Here is some skeleton code we can use as a common basis. Main.qml
ApplicationWindow {
visible: true
width: 640
height: 480
title: "Update UI Test"
header: ToolBar {
ToolButton {
id: toolButton
text: "?"
}
}
TabView {
id: tabView
anchors.fill: parent
Tab {
title: "Tab 1"
PageTest {
}
}
Tab {
title: "Tab 2"
PageTest {
}
}
}
}
PageTest.qml
Page {
property alias checked: checkBox.checked
CheckBox {
id: checkBox
x: 200
y: 100
text: "Enable"
}
}
I have no idea how to connect the dots in order to get this working.