You can implement your own QTableWidget item that will handle comparison in a special way. For example:
class TableItem : public QTableWidgetItem
{
public:
TableItem(const QString & text)
:
QTableWidgetItem(text)
{}
TableItem(int num)
:
QTableWidgetItem(QString::number(num))
{}
bool operator< (const QTableWidgetItem &other) const
{
if (other.column() == 1) {
// Compare cell data as integers for the second column.
return text().toInt() < other.text().toInt();
}
return other.text() < text();
}
};
With this, you will simply have to create TableItem
instead of QTableWidgetItem
:
ui->tableWidget->setItem(i, 1, new TableItem(tr("%1").arg(lijst[i].nroFrames));
or
ui->tableWidget->setItem(i, 1, new TableItem(lijst[i].nroFrames);