Sorting in QtableView



  • Hi All
    I have query in sorting a column in QtableView . One of the ways to sort a column in Qtableview

    try using QSortFilterProxyModel

    an example:

    @ QSortFilterProxyModel *sort_filter = new QSortFilterProxyModel(this);
    sort_filter->setSourceModel(model);
    sort_filter->sort (0);
    this->ui->data_table->setModel (sort_filter);

    Now my question is is the best way to sort the column ?

    Also when a sort the column does the QModelIndex of the each row changes or it remains the same


  • Lifetime Qt Champion

    Hi,

    That's the official way.

    You should rather write a quick test to verify the index handling. That would have answered the question faster.


Log in to reply
 

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