开发者

Qt QTreeWidget preserve sort

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜