Header from tableview doesnt update after sorting
-
Hi,
Are you using a custom model ?
-
Reset the model ?
Are you also re-implementing the headerData method ?
-
Yes, with emit beginresetmodel and endresetmodel. I need my model updated every second.
Yes, like this
if (role != Qt::DisplayRole) return QVariant(); if ( orientation == Qt::Vertical ) { ... return bla; } if(orientation == Qt::Horizontal) { if(section == 0) { return blabla1 } if(section == 1) { return blabla2 } } return QVariant();
-
@Maser
instead of resetting the whole model (when it's not necessary) you should only emit the changed signals of the data which has actually changed. And let Qt do the optimization.So emit headerDataChanged() instead.
-
Even if all the data is changed, you can emit a dataChanged for the whole model.
resetModel is usually used when the model layout changes, which doesn't seems to be your case.
-
@Maser
to add up to @SGaist
a model reset is more radical approach of telling the view that the data has changed.
A model reset implies that the selection and current gets lost, the current scroll position is reset, ...
So you should only reset (also from the user experience point of view) when the structure of the model changes. But as long as just the "content" of existing items change you should emit the dataChanged() signal instead.