I have a problem with my call to QTableView.selectionModel(). I instanciate my QTableView in another class, then when I open a new project and need to fill in my view I call a function fillGrid() in which I get the data among other things. This is also where I call the selectionModel() method.
Everything goes well the first time I call it. But if I try to call it again in the same instance of the program then it gives me the following error :
TypeError: 'QItemSelectionModel' object is not callable
my function fillGrid looks like :
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.view开发者_StackOverflow中文版port().installEventFilter(self)
self.setItemDelegateForColumn(13,ComboBoxDelegate(self, self.checkValues))
self.setColumnWidth(13, 64)
Any idea why this is happening ? Thanks in advance
You've assigned your QItemSelectionModel instance to the name selectionModel, but selectionModel is a method of the QTableView class. You need to pick a new name for your selection model. See the QAbstractItemView class reference.
If you want to assign that selection model to apply to your model you need to use the setSelectionModel method.
精彩评论