I'm sorting a QTableWidget object with the sortItems() function.

Qt Code:
  1. QTableWidget myTable = new QTableWidget(rows, columns, this);
  2. myTable->sortItems(1, Qt::AscendingOrder);
To copy to clipboard, switch view to plain text mode 

Everything works fine but ascendingly rows are sorted like this:
1,.........................
10,......................
2,.......................
3.......................
etc.

In other words, this sort Items function thinks that 2>10 because 10 starts with a 1. How could I avoid this and make it consider number 10 as something that's bigger than 9 and smaller than 11.
This problem may have something to do with how I load myTable with integers. This is how it's done (do you see a problem with it):

Qt Code:
  1. QTableWidgetItem *item = new QTableWidgetItem(QString::number(integer));
  2. myTable->setItem(y, x, item);
To copy to clipboard, switch view to plain text mode 

Later the sorted integers are extracted from myTable like this:
Qt Code:
  1. QTableWidgetItem *a = myTable->item(y,x);
  2. int val = a->text().toInt();
To copy to clipboard, switch view to plain text mode 

Thank you!