开发者

Qt QTreeWidget preserve sort

开发者 https://www.devze.com 2022-12-19 06:29 出处:网络
How do you implement a preserve sort in a Qt QTreeWidget?I.e. I would like the previous order of the tree preserved as much as possible. This allows the user to do something like click the \"Name\" co

How do you implement a preserve sort in a Qt QTreeWidget? I.e. I would like the previous order of the tree preserved as much as possible. This allows the user to do something like click the "Name" column header and then the "Date" column h开发者_运维百科eader, and the resulting tree shows the items in the QTreeWidget by Date and then by Name.


Unfortunately, you can't. QTreeWidget uses an inaccessible (and internal) QTreeModel for its operations, including sorting.

Normally, to do so you would want to implement a stable sort within your QAbstractItemModel subclass. A stable sort will leave items whose position doesn't need to change in the same location.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号