Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to notify QtreeView to refresh
Qt Enthusiast last edited by Qt Enthusiast
I have a two views .
- One is of QGraphicsView and other is QTreeView with custommodel .
- I make some changes in QTreeView. I want to notify the QTreeView that data is updated and QTreeView should start fetching data again . Means its custom model should call ::data
Can some one guide me how to the same through code
Ratzz last edited by
You can refresh model using http://doc.qt.io/qt-4.8/qabstractitemmodel.html#layoutChanged .
in your setData() method (or wherever you change your data) you need to emit QAbstractItemModel's dataChanged() signal for the indexes which have changed.
i works because a relayout implies also a repaint which regathers the data again from the model, but i wouldn't use layoutChanged() since the layout is simply not necessary.
-AVM last edited by
This post is deleted!
Qt Enthusiast last edited by
One more case If I make any changes in QGraphicsView and if from QGraphicsView, If I want to notify QTreeView that please update the view and get new data from ::data . Can some one guide me on this
you need to be more specific...
The model handles the data. Whenever the data in the model changes emit dataChanged(). And every view which uses the model will get updated.