Details
Description
Run the following code and you will get the error
# Error: line 1: TypeError: file <maya console> line 29: dataChanged(QModelIndex,QModelIndex,QVector<int>) only accepts 3 arguments, 3 given! #
from PySide2 import QtGui def on_data_changed(top_left, bottom_right, roles=None): print "Data changed, TL: %s, BR: %s, Roles: %s" % (top_left, bottom_right, roles) class SignalWrapper(object): def __init__(self, signal): self._signal = signal def emit(self, tl, br): self._signal.emit(tl, br, []) def __getattr__(self, name): return getattr(self._signal, name) class MyModel(QtGui.QStandardItemModel): def __init__(self, parent=None): QtGui.QStandardItemModel.__init__(self, parent) # adding this line will patch the dataChanged signal to behave like the PySide1 version #self.dataChanged = SignalWrapper(self.dataChanged) def emit_data_changed(self): top_left = self.index(0, 0) bottom_right = self.index(0, 0) roles = [1,2] # this works: # self.dataChanged.emit(top_left, bottom_right, roles) # this doesn’t unless you uncomment the ‘fix’ in __init__ self.dataChanged.emit(top_left, bottom_right) # PySide1 version model = MyModel() model.dataChanged.connect(on_data_changed) model.emit_data_changed()
Attachments
Issue Links
- duplicates
-
PYSIDE-333 Methods with default arguments don't always work
- Closed
- resulted in
-
PYSIDE-475 Handle signals through XML files
- Closed