-
Sorting disabled?
Hi,
im relatively new to QT and am clueless right now.
I have a QTablewidget, that i populate with "table->setCellWidget(row, column, new QLabel(somestuff))" while populating setSortingEnabled is disabled and after the populating is finished re enabled.
The sortIndicator seems to work somehow. By clicking the Columns the indicator changes, but nothing else. The order of the table stays the way it was before. Nothing changes at all in the table.
What could i have done to disable sorting all together, or are additional steps needed for the sorting to work at all?
Edit: sortByColumn and sortItems also have no effect on the Table.
I'd love to hear some answers. And have a great day.
Random Guy
-
Re: Sorting disabled?
You should use a model instead of setting widgets directly.
https://doc.qt.io/qt-5/model-view-pr...sing-reference
Also why are you using a QLabel? If you just want to show a string, that's total overkill.
Sorting doesnt work because Qt wont look into the label to find your string and sort by that. It cant sort widgets.
-
Re: Sorting disabled?
Thanks.
Tried with all kinds of other Types for Strings and numbers. The only one that worked at that time were Labels then i just kept them.
Edit: Topic can be closed.
TL;DR: CellWidgets will not be sorted.