1

I have a QTableWidget with many columns and I want to allow sorting only by specific columns. Enabling sorting for the whole table with setSortingEnabled(1) makes the table sortable by all columns,

In this example

Name        Read    Comment
whatever1    0      bla 
whatever2    0      bla
whatever3    1      bla

I want to sort the table only by column "Read" and only with the operator <.

Is there a function or slot that I can execute after each cell changes?

self.ui.table.connect.cellChanged(self.sort_by_read)
NoDataDumpNoContribution
  • 10,591
  • 9
  • 64
  • 104
Elteroooo
  • 2,913
  • 3
  • 33
  • 40
  • Does this question help? http://stackoverflow.com/questions/21973912/pyqt-qt4-qtableview-how-to-disable-sorting-for-certain-columns – Andy Jul 29 '14 at 04:31

1 Answers1

1

There exists PySide.QtGui.QTableWidget.sortItems(column[, order=Qt.AscendingOrder]) for sorting items by one specific column.

http://srinikom.github.io/pyside-docs/PySide/QtGui/QTableWidget.html#PySide.QtGui.PySide.QtGui.QTableWidget.sortItems

Liteye
  • 2,761
  • 1
  • 16
  • 16