How to notify QtreeView to refresh
-
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
-
@Qt-Enthusiast
You can refresh model using http://doc.qt.io/qt-4.8/qabstractitemmodel.html#layoutChanged . -
@Qt-Enthusiast
in your setData() method (or wherever you change your data) you need to emit QAbstractItemModel's dataChanged() signal for the indexes which have changed.@Ratzz
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. -
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
-
@Qt-Enthusiast
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.