Hi, assuming the checkboxes and the combo boxes are different data types (bool, vs, string) and thus displayed in different columns, sorting should happen automatically when you setSortingEnabled(True). Please note that you have to disable sorting while inserting items because this may lead to stringe behaviour. Also if you want to display checkboxes these should be set by QTableWidgetItem.setFlags(QTablewidgetItem.flags() | Qt.ItemIsUSerCheckable)) and setCheckState() rather than doing a QTableWidget.setCellWidget(), because this is way faster. The combooxes can be inserted with setCellWidget, but be aware that you may run into performance issues if you add a lot of them.
Alternatively you could subclass the QTableWidgetItem and override the < operator to provide your own sorting, which will be - of course - solower because implemented in python. Finally when dealing with large datasets I would recommend going for the true model/view approach with QTableView, QTableModel and QStyledItemDelegate, but those are more hard to use. Cheers Sebastian Am 06.04.2012 02:50, schrieb Frank Rueter | OHUfx: > Hi guys, > > I'm working on a table that has ItemWidgets (comboBoxes, checkBoxes etc) > in some cells and I'm trying to figure out how to write a custom sort > behaviour that will enable me to sort the table by columns containing > widgets using the respective widgets' current value (e.g. show all rows > with a checked checkBox first, followed by all rows with an unchecked > checkBox). > > Has anyone done this before? > Any pointers would be fabulous! > > Cheers, > frank > > _______________________________________________ > PySide mailing list > [email protected] > http://lists.qt-project.org/mailman/listinfo/pyside _______________________________________________ PySide mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/pyside
