Either set the numbers as integers, not as text or provide a custom QTableWidgetItem::operator<().


Approach 1:
Qt Code:
  1. int i = 0;
  2. QTableWidgetItem* item = ...;
  3. item->setText(QString::number(i)); // don't use this
  4. item->setData(Qt::DisplayRole, i); // but this
To copy to clipboard, switch view to plain text mode 

Approach 2:
Subclass QTableWidgetItem, override QTableWidgetItem::operator<().