Reply
Thread Tools
marxian's Avatar
Posts: 2,448 | Thanked: 9,523 times | Joined on Aug 2010 @ Wigan, UK
#11
Originally Posted by solbrit View Post
Say I have a page stack which from bottom to top goes "a.qml" -> "b.qml" -> "c.qml".

- pageStack.push(Qt.resolvedUrl("b.qml")) will get me from a to b
- pageStack.pop() will take me back from b to a

However nothing happens when I try giving pop a page argument, ie going from a to b, then from b to c, and then from c going DIRECTLY back to a with:

- pageStack.pop(Qt.resolvedUrl("a.qml"))

Why is this? How can I go directly back to the first page?
The problem here is that you are passing a new instance of the component defined in "a.qml" as the first argument to pop(). Instead, it should be an existing instance. You can also pass null if you want to return to the first page, e.g.

Code:
pageStack.pop(null)
To pop to an existing page, you pass the id, e.g

Code:
pageStack.pop(myPage)
In many cases, myPage will not be in scope, so you can use the find() function to find a page.
__________________
'Men of high position are allowed, by a special act of grace, to accomodate their reasoning to the answer they need. Logic is only required in those of lesser rank.' - J K Galbraith

My website

GitHub
 
solbrit's Avatar
Posts: 126 | Thanked: 59 times | Joined on Jan 2011
#12
Thanks for your answer! However pop(null) will in my case do the same as pop(), ie go back one step only. I'll look into find()...
 
solbrit's Avatar
Posts: 126 | Thanked: 59 times | Joined on Jan 2011
#13
Using find() at best I get the same result as with pop() and pop(null), it'll pop the top most page off, but not more.

Edit: As a workaround I thought I'd try clear() and then push the first page, but no luck so far. The stack is cleared allright, but I'm not sure how to push the first page after that..

Last edited by solbrit; 2014-04-01 at 23:06.
 
solbrit's Avatar
Posts: 126 | Thanked: 59 times | Joined on Jan 2011
#14
Okay, keeping it simple I made this experiment:
1: I create the basic app in SDK
2: I create a new qml page "ThirdPage.qml"
3: I pretty much copy the "FirstPage.qml" contents to "SecondPage.qml" and "ThirdPage.qml", changing the PullDownMenus' MenuItem to:

SecondPage.qml:
Code:
MenuItem {
    text: "Show Page 3"
    onClicked: pageStack.push(Qt.resolvedUrl("ThirdPage.qml"))
}
ThirdPage.qml:
Code:
MenuItem {
    text: "Show Page 1"
    onClicked: pageStack.pop(null)
}
So, even in this basic test the "pageStack.pop(null)" on "ThirdPage" only pops off one page, uwinding to "SecondPage", when it ought to take you back to the "FirstPage" (stack bottom). Why doesn't it? What am I doing wrong? Or is it a bug? If I remember correctly this is the way I did it in Harmattan, but in Sailfish it doesn't work...
 
Reply


 
Forum Jump


All times are GMT. The time now is 09:13.