Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Sort widgets in QTableWidget?
sherief last edited by sherief
So I have a custom QTableWidget class that I use as a database. My goal is to is to have a push button on top of each column that lets me sort the data in that column.
I've been able to do it for simple data entries such as name and numerical id using table.sortByColumn, but I have a checkbox in the last column that represents whether or not that person has admin privileges. Is there any way to be able to sort my table based on who has admin privileges?
The problem is that it's a cellWidget so I'm not sure how to be able to sort in de/ascending order. Ideally, I want to have some kind of backend data where 1 means admin and 0 means user and sort based on that, but again, I'm not sure how to be able to use sortByColumn with that considering it's still a widget at that cell and not a strong or number.
@sherief You can subclass QTableWidgetItem for your table items and override https://doc.qt.io/qt-5/qtablewidgetitem.html#operator-lt