You can implement the items as properties rather than children, which will result in them not showing until they are pushed on the stack view:
property Item item0: MyItem0 { }
property Item item1: MyItem1 { }
However, if you pop, the item will remain visible, as its parent will no longer be null.
pop()
is said to return the popped item, so pop().parent = null
should do the trick, but for me for some reason it returns a null
.
So instead you can simply set the parent explicitly to null:
pop()
item0.parent = null
Naturally, you can just as well set the visible
or opacity
properties. Which may be preferable, as even more funky and illogical behavior surfaces. if you try to push the same item again after it has been pushed and popped once, it doesn't work, and there is an nothing to push
error message in the debug console.
Edit: OK, regarding the last paragraph, it seems that whatever method used, once an object has been pushed and popped, the same object cannot be pushed again, even if the parent is not set to null. This looks like a bug.