Hi,
I know my problem is due to Lazy-loading mechanizm, but I just can’t figure out how to work around this problem.
I have two pages in main Navigation and second page has also AppTabBar with several pages. What i need is to set mainNavigation.currentIndex=1 and appTabBar.currentIndex=0
However because of Lazy-loading “settingsPage is not defined” when I try to access it from main.qml
According to this page Working with TabView’s Loader sandbox effect there are some ways dirty or not but none of them works for me, can you give me some advice?
Main.qml
signal goToAddProgram()
Navigation {
id:mainNavigation
anchors.fill: parent
visible: true
navigationMode: navigationModeDefault
property alias configNaviItem: configNaviItem
NavigationItem {
id:homeNaviItem
title: "Programs"
icon: IconType.home
NavigationStack {
id: progNaviStack
Prog1Page {
id: prog1Page
}
}
}
NavigationItem {
id:configNaviItem
title: "Config"
icon: IconType.home
NavigationStack {
id: configNaviStack
SettingsPage {
id:settingsPage
}
}
}
}
onGoToAddProgram: {
mainNavigation.currentIndex=1
//what I need is to show first page from SettingsPage
//settingsPage.appTabBar.currentIndex=0
}
SettingPage.qml
Flickable {
id: tabFlickable
anchors.top:parent.top
anchors.topMargin: dp(Theme.navigationBar.height*1.5)
width: parent.width
height: dp(Theme.tabBar.height)
contentWidth: appTabBar.width
contentHeight: height
AppTabBar {
id: appTabBar
width: 900
translucency: 1
AppTabButton {
text: "Program"
}
AppTabButton {
text: "Section"
}
AppTabButton {
text: "Device"
}
AppTabButton {
text: "Alarm"
}
AppTabButton {
text: "Settings"
}
}
}
// content area
Loader {
id: content
anchors.top: tabFlickable.bottom
anchors.bottom: parent.bottom
width: parent.width
source: "Tab"+appTabBar.currentIndex+"Page.qml" // load different page based on selected tab
}
Best Regards
Marek