I could reproduce this.
When the new line filesTable->setSortingEnabled(true); is moved after the call of findFiles() (line 132) the file sizes are displayed correctly.
So the sorting does weird things to table content.
But honestly I believe that the problem lies not in Qt itself, but in the example.
The example inserts a row and afterwards fills file name and file size to the row.
When sorting is enabled the row number that showFiles() uses is not the number where the row was inserted. The sorting moved the row.
If the example should work it should either sort after inserting all rows (see above) or better take care of where QTableWidgetItems are inserted.
Bookmarks