QT QItemSelectionModel to ignore columns?

前端 未结 2 1284
情书的邮戳
情书的邮戳 2021-01-25 07:08

I am trying to restrict selection of a tree to a particular column.

I am using delegates heavily to create custom per-item-per-column behaviors, editors, etc. I was hop

2条回答
  •  再見小時候
    2021-01-25 07:29

    The following adjustment should work, in theory.

    The above solution could use two separate methods and @pyqtSlot decorators to disambiguate the overloaded method names:

    @pyqtSlot(QModelIndex, QItemSelectionModel.SelectionFlags)
      def select(self, index, command):
        # ...
    
    @pyqtSlot(QItemSelection, QItemSelectionModel.SelectionFlags)
      def select(self, selection, command):
        #...
    

    This avoids the need to check for instances of certain classes in the method implementations.

提交回复
热议问题