简体   繁体   中英

Qt 5.3.1 TableView not updating

Recently I upgraded from Qt 5.3.0 to Qt 5.3.1 and noticed that my TableView's which use a QSortFilterProxyModel as their model no longer update when I sort the proxy model.

You can see this in action by using the sample code here !

If you compile it with Qt 5.3.0 the table will sort but if you compile it with Qt 5.3.1 the model will sort (verified with qDebug statements) but the TableView will not update. This happens on both Windows and Linux.

To get around it I had to add emit layoutChanged() after I call this->sort().

My question is has anyone else noticed this and found out if this is by design or is a defect.

Thanks

I did a little more digging and I found a Qt bug filed for exactly this issue. QTBUG-40035 TableView, Sort doesn't work .

Turns out in Qt 5.3.1 another bug was resolved QTBUG-37983 which changed the QQMLDelegateModel to emit layoutChanged( QList, QAbstractItemModel::LayoutChangedHint) instead of simply emitting layoutChanged(). The TableView does not seem to be listening to the parameratized version of the layoutChanged() signal which is why I can fix this by manually emitting layoutChanged() after I call sort().

This apparently has been fixed by QTBUG-39492 in Qt 5.3.2

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM