02-11-2013 02:30 PM
Hello everyone,
I bet that I missed this thing in documentation, but need you help here. So I have a NavigationPane and stack of screens. On screens I have a home button to go back to the "parent" screen. How can I remove all pages from navigation stack exept the first one? I don't really want to push first screen again, because that way I will have to hide back button on bar and i think it is not good for memory.
Any suggestions?
Solved! Go to Solution.
02-11-2013 03:47 PM - edited 02-11-2013 03:49 PM
Hi,
I think you can use navigateTo method for this (+navigateToTransitionEnded signal to destroy the pages).
Pass the first page to navigateTo. It can be retrieved using navigationPane.at(0)
Btw in Cascades if you drag the back button (not the screen itself), it will go straight to the top so separate button may not be neccessary.
02-11-2013 03:52 PM
Hello Zmey,
Thanks for your suggestions. Will try to do that way. As for back button - I know that, but since I'm developing an app for a client I cannot do everything as I want to.
02-11-2013 05:22 PM - edited 02-11-2013 05:32 PM
Here's how I've done it, and it should work assuming your root page is the first item pushed onto the stack (which I assume it always will be).
while(nav->count() > 1)
{
nav->pop();
}Where nav is a pointer to a NavigationPane.
edit: So assuming you're willing to do this in C++ just connect the ActionItem triggered() SIGNAL to a SLOT that can access the navigation pane through a class variable.
If you're looking for a fully QML solution you could override the back button functionality:
paneProperties: NavigationPaneProperties {
backButton: ActionItem {
title: "First page"
imageSource: "back.png"
onTriggered: {
navigationPane.pop();
}
}
}I don't think you can use NavigationPaneProperties in any way to include both a regular back button and a "back to root" button. I'm sure there's a good way to do it in QML but I'm too familiar with QML as I've done this kind of logic mostly in C++.
02-12-2013 04:03 AM - edited 02-12-2013 04:04 AM
Thanks everyone. Basically it will look like this
nav.navigateTo(nav.at(0));