how to refresh the appearance when the listmodel data has changed in a stackview ?
-
@hasson That should be automatically the case when dataChanged() signal was emitted after changing data.
-
but what i saw is that the page didn't changed until re-push it
-
@hasson
by "re-pushing" you recreate your (List?)View, meaning it itself - without reacting to the signal - fetches the data from the c++ model.The fact that it only does this when recreated means there's either something wrong in the model binding (possibly broken) or your c++ model does not in fact emit the modelChanged signal.
Impossible to tell, until you share some code with us
-
thanks, my c++ model does not in fact emit the modelChanged signal
-
Hi @hasson,
you can try this.
first emit one signal from your c++ class, lets say emit listmodelChanged() each time whenever your listmodel changes and in qml follow the code.
StackView { id:stack } Connection { target:yourCppObject onListmodelChanged: { stack.pop(null) } }
-
@hasson said in how to refresh the appearance when the listmodel data has changed in a stackview ?:
the listmodel data is from c++
What do you mean by that?
What is the type of your model and how do you update it in c++? -
@sharath thanks, but i don't want to pop any item when data changed
-
Hi@grecko the model is inherit from QAbstractListModel, and i update it by writing data direct
-
If you call the
dataChanged
signal and the[begin|end][Insert|Remove]Rows
functions appropriately, it should work out of the box. -
@grecko said in how to refresh the appearance when the listmodel data has changed in a stackview ?:
it should work out of the box.
because of not using dataChanged signal,it doesn't work,,now it's working,
thank you!