Search code examples
c++qtqtablewidget

Sorting QTableWidget by column


I have a QTableWidget and I want to sort the components of this table according to the values of the zero column, I used this code :

ui->tableParticle->sortByColumn(0,Qt::AscendingOrder);

but it gives no good results, the image below shows you the problem I sought solution but found nothing, sorry I can't put all the code because it's very long.

Image


Solution

  • I add that before setItem and it's work :

    ui->table->horizontalHeader()->sortIndicatorOrder();