Unsolved How to refresh listview in QML
-
Hi,
How can I refresh a listview in QML when I add a new entity ??!!
Please help me. -
Hello! Please, use the forceLayout function. This method forces the ListView to immediately respond to any outstanding changes in the model (documentation).
-
How can I use it !!!
-
Why do you think you need to refresh the view? It should automatically get updated on model changes.
-
Call the function forceLayout on your ListView, after updating the model.
-
The documentation tells that :
Responding to changes in the model is usually batched to happen only once per frame. This means that inside script blocks it is possible for the underlying model to have changed, but the ListView has not caught up yet.
So this method forces the ListView to immediately respond to any outstanding changes in the model.
-
@Wieland It get updated when I run the application one more time, but I want refresh it when I add a new entity in my data base without close and run the application every time.
-
@ibia thank you, I will try it and I hope it works
-
You're welcome! I hope it helped.