void QTableWidget::sortItems
-
HI, it seems that this function see that "999999" is greater than "1000000" because there are only QString and not numbers(long...) in the QTableWIdgetItem.
SO I should sort my list before to put it in the QTableWIdgetItem, and I should not use this method void QTableWidget::sortItems
is this a bug of Qt? -
QTableWidget compares according to QVariant http://doc.qt.io/qt-5/qvariant.html#operator-lt if you pass the numbers as strings they will be sorted as strings.
how do you insert data in the QTableWidget?
-
setItem(i,1,new QTableWidgetItem(QString::number(penv->getId())));
where getId() returns a long,but I insert it as a QString and I don't see any other choice because the constructor of QTableWIdgetItem takes a QString and not a number.
-
@VRonin , HI, thank you I didn't know that.But this column is hidden.does it matter ?
-
@stephane78 said:
this column is hidden.does it matter ?
No, hiding the column depends on the view, the data in the column depends on the model so no direct implication. see Model/View Programming
-
@VRonin, ok thank you .do you think that sortItems will run correctly by this way (by putting a number in the column) ?