Nominate our 2022 Qt Champions!

sorting problem...same contents but 2 view (QListWidget and QTreeWidget)

  • sorting problem...same contents but 2 view (QListWidget and QTreeWidget).
    i use QListWidget and QTreeWidget in a QStackedWidget to represent same Contents, because i want to preview in multi-column ListMode from QTreeWidget, IconMode from QListWidget...
    right now, i can click on the Header of the QTreeWidget to sort the items, but after sorting in QTreeWidget, when i switch to IconMode which is in QListWidget, i want the items order is the same with the sorted items order in QTreeWidget...
    how can i do this ?

  • can i have a try like this? because 1. the user are only allowed to sort in the QTreeWidget, by click on the multi-column Header. 2. both the items in QTreeWidget and QListWidget have a same data which is used setData() to the Item.

    1. click the Header in the QTreeWidget, sort it.
    2. get the items in the QTreeWidget(because it's designed that there only 1 level children)
    3. based sorted QTreeWidget's items Data, sort(or clear and re-create) the items in the QListWidget.

Log in to reply