Updating Scrollbar QTableView when model shrink
-
Hello,
I have a model that dynamically shrinks and grows depending on user inputs and it is display in a tableview... the problem I'm having is that the scrollbars are never updated... they are set to the size of the data when I call setModel().. but when the model shrinks I can still scroll past the new smaller data... I've tried calling reset() and update() on the tableview but it has no effect on the scrollbar... How can I update the scrollbar so that it doesn't go past the size of the data??
-
Hi,
Sounds like a glitch, what version of Qt are you using ? On which platform ?
-
If you are using custom model, it mostly likely a sign that model does not call appropriate required functions which are used for notification about data changes.
-
@alex_malyu Yes, it is a custom model... and you are right I do not call any function when I change the data... I simply have a setter function that sets the model data... how should I go about changing the data??
-
@alex_malyu The custom model derives from QAbstractTableModel btw...
-
look at:
https://doc.qt.io/archives/4.6/model-view-creating-models.html
and
http://doc.qt.io/qt-5/qabstractitemmodel.htmlfunctions of interest typically start with begin...., end...
like:
void beginInsertRows(const QModelIndex & parent, int first, int last)
void beginRemoveRows(const QModelIndex & parent, int first, int last)
void beginResetModel()
....