How to set QTableView columns position



  • I have a QTableView, with QSqlRelationalTableModel as a model providing datas.

    My database (sqlite) was like :
    1 id / 2 date / 3 time / 4 identifiant / 5-6-7-8... others fields
    I 've added a new column : x identifiant2, which is AFTER all others.

    Then in my Table it is shown at the end (was expecting that since it use the db model).

    I want to re-order columns to be displayed as "id date time identifiant identifiant2 whatever foo bar baz".

    How i can achieve that ?

    I've tried to find something but all i got in the web is about sorting rows by columns... thanks.



  • I believe QHeaderView::moveSection(int from, int to) is your friend.


Log in to reply
 

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