How to restore the default of columns in a QTreeView

  • I have a QtreeView

    Column_ and each column width is 10
    A B C

    Now I do multiple operations
    like Columm B
    Move Column C in front and Move column A to back

    Increase the width of column C by mouse

    I need to functionality where I need reset the column width and order


    it is should show columns
    A B C with default width as 10

  • @Qt-Enthusiast
    There is no "reset the column width and order" for a tree view (QHeaderView), it doesn't know its initial state. Other than throwing it away and creating a new one, it would be up to you to save the initial order/widths and reset to that yourself in code. You might leverage QHeaderView::save/restoreState to help you, but still requires you to take that action if that's what you want.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.