Updating pages in the pageStack
On the FirstPage we have a list of things. On the Create page we create an item to the list and do a pageStack.replace(firstpage) so that it "reloads" the firstpage (which has a function for filling the list) adds the new item on the list and display the updated first page. All nice up to here.
However this approach leaves -if you swipe back- a non updated First page. Trying to pop the non updated first page didn't seem to work. Using pop from the create page doesn't update the first page.
Is there a way to remove the non updated first page from the list?
Updated the title to reflect the problem/discussion (see comments).
Edit 2: Somehow solved but there must be a more correct/better way.
if i change Component.onCompleted: { } on the first page with onStatusChanged: { } it updates the list however it breaks the model i pass to the edit dialog. Also it seems to call the functions in onStatusChanged more than it is necessary and seems kind of wasteful.
:/
What if you used a dialog insted of a page for the Create page? Then you could assign stuff to onCancelled
jollailija ( 2015-12-13 12:40:46 +0200 )editOr, you could use listView.clear() when going to the create page and refill the list when the list page is activated again.
jollailija ( 2015-12-13 12:41:37 +0200 )editI want two actions from the create page so i have to use a page with a two item pulley. I use a dialog when i edit the connection but this gives other king of headaches that i will look into after sorting this.
The problem isn't the list at least with the approach i took now. Its how i get rid of the non updated page it leaves behind. I end up with two FirstPage.qml pages on the stack. (one updated and one not updated). And i don't think there is a way to remove a page by specifying the position on the stack or something like that. :/
ApB ( 2015-12-13 13:51:12 +0200 )editThere is no need to use pageStack.replace or other complicated programming. Use a normal pop(). If you use a simple list for your model take the insert or append methods of QML type ListModel. If using a database save your new data and reread the ListModel. Simple programming is hard enough.
utkiek ( 2015-12-13 15:54:07 +0200 )edit@utkiek
The thing is that i will have to call the function in the firstpage qml from the create QML file. Signals and all that stuff is something i don't quite understand yet. Hence using replace and poping the previous page seemed like a simpler solution.
ApB ( 2015-12-13 16:31:52 +0200 )edit