I tried another solution with dynamic page creation, but "tools" property can't be set without blinking of ToolBarItems in the middle of the page, try this code
import QtQuick 2.0 import Ubuntu.Components 0.1 import "ui"
/*! \brief MainView with Tabs element. First Tab has a single Label and second Tab has a single ToolbarAction. */
MainView { // objectName for functional testing purposes (autopilot-qt5) objectName: "mainView"
// Note! applicationName needs to match the "name" field of the click manifest applicationName: "com.ubuntu.developer.mrqtros.ToolbarBug"
width: units.gu(50) height: units.gu(75)
Tabs { id: tabstabs
Tab { id: someTab title: i18n.tr("..World!")
property bool mode: false
page: mainLoader.item
Loader { id: mainLoader
sourceComponent: someTab.mode ? secPageComp : fstPageComp }
Component { id: fstPageComp
Page { id: firstPage
visible: !someTab.mode anchors.fill: parent
Label { anchors.centerIn: parent text: "Page 1" }
tools: firstTools } }
ToolbarItems { id: firstTools
ToolbarButton { iconSource: Qt.resolvedUrl("graphics/toolbarIcon.png") text: i18n.tr("Tap 1!")
onTriggered: { someTab.mode = !someTab.mode } } }
Component { id: secPageComp
Page { id: secondPage
visible: someTab.mode anchors.fill: parent
Label { anchors.centerIn: parent text: "Page 2" }
tools: secondTools
ToolbarItems { id: secondTools
ToolbarButton { id: brtTool
iconSource: Qt.resolvedUrl("graphics/toolbarIcon.png") text: i18n.tr("Tap 2!")
onTriggered: { someTab.mode = !someTab.mode } } } } } } } }
I tried another solution with dynamic page creation, but "tools" property can't be set without blinking of ToolBarItems in the middle of the page, try this code
import QtQuick 2.0
import Ubuntu.Components 0.1
import "ui"
/*!
\brief MainView with Tabs element.
First Tab has a single Label and
second Tab has a single ToolbarAction.
*/
MainView {
// objectName for functional testing purposes (autopilot-qt5)
objectName: "mainView"
// Note! applicationName needs to match the "name" field of the click manifest Name: "com.ubuntu. developer. mrqtros. ToolbarBug"
application
width: units.gu(50)
height: units.gu(75)
Tabs {
id: tabstabs
Tab {
id: someTab
title: i18n.tr("..World!")
page: mainLoader.item
Loader {
id: mainLoader
}
id: fstPageComp
}
}
id: firstTools
}
}
id: secPageComp
}
}
}
}
}