PyQt5 QTableView Method for setting a column to be non editable

  • 2021-07-01 08:01:49
  • OfStack

As shown below:


class EmptyDelegate(QItemDelegate):
  def __init__(self,parent):
    super(EmptyDelegate, self).__init__(parent)
 
  def createEditor(self, QWidget, QStyleOptionViewItem, QModelIndex):
    return None

Write a proxy.


self.tableView.setItemDelegateForColumn(2,EmptyDelegate(self)) #  Set the 2 Column is not editable 

Just set 1.


Related articles: