how to refresh the QTreeView and QtableView
-
I have DIalog
- QTreeview with Custom Model
- QTableView with Custom Model
on clicking on Finding , I have to refresh the both Qtreeview and QTableview .
A
B
CD
E
F- How to ask the QAbstractModel to start fetching the data again
Can someone help me in writing the refresh functions for both
-
[protected] void QAbstractItemModel::beginResetModel()
Begins a model reset operation.
A reset operation resets the model to its current state in any attached views.
Note: Any views attached to this model will be reset as well.
When a model is reset it means that any previous data reported from the model is now invalid and has to be queried for again. This also means that the current item and any selected items will become invalid.
When a model radically changes its data it can sometimes be easier to just call this function rather than emit dataChanged() to inform other components when the underlying data source, or its structure, has changed.
You must call this function before resetting any internal data structures in your model or proxy model.
This function emits the signal modelAboutToBeReset().
This function was introduced in Qt 4.6.
See also modelAboutToBeReset(), modelReset(), and endResetModel(). -
Maybe you could inherit from QSortFilterProxyModel, code the find method according to some internal criteria and use it for both views?
Here is an exemple: http://doc.qt.io/qt-5/qtwidgets-itemviews-customsortfiltermodel-example.html