我对 QTableView.selectionModel() 的调用有问题。我在另一个类中实例化我的 QTableView,然后当我打开一个新项目并需要填写我的视图时,我调用一个函数 fillGrid(),在其中我获取数据等。这也是我调用 selectionModel() 方法的地方。
我第一次调用它时一切顺利。但是,如果我尝试在程序的同一实例中再次调用它,则会出现以下错误:
TypeError:“QItemSelectionModel”对象不可调用
我的函数 fillGrid 看起来像:
def fillGrid(self):
self.infos = select.getInfosProject(self.parent.db, self.parent.currentProj)
self.getData()
header = ["id","hidden","state","filename","asset-shot name","task","buffer","pass","camera","version","user","date","deps","check","comment","start frame","end frame","missing frames","edit start frame","edit end frame"]
self.model = SequenceGridModel(self.data, header, self)
self.setModel(self.model)
self.hideColumn(0)
self.hideColumn(1)
font = QtGui.QFont("Verdana", 8)
self.setFont(font)
vh = self.verticalHeader()
vh.setVisible(False)
hh = self.horizontalHeader()
hh.setStretchLastSection(True)
self.resizeColumnsToContents()
self.setSelectionBehavior(QtGui.QTableView.SelectRows)
self.selectionModel = self.selectionModel()
self.connect(self.selectionModel, QtCore.SIGNAL("selectionChanged(QItemSelection, QItemSelection)"), self.getSelection)
self.setSortingEnabled(True)
self.setEditTriggers(QtGui.QAbstractItemView.CurrentChanged)
self.viewport().installEventFilter(self)
self.setItemDelegateForColumn(13,ComboBoxDelegate(self, self.checkValues))
self.setColumnWidth(13, 64)
知道为什么会这样吗?提前致谢