Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to refresh listview in QML
How can I refresh a listview in QML when I add a new entity ??!!
Please help me.
ibia last edited by ibia
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 !!!
A Former User last edited by
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.
jiji last edited by jiji
@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.