尝试发出dataChanged
信号时出现此错误:
self.dataChanged.emit(index, index)
TypeError: Value types used on meta functions (including signals) need to be registered on meta type: QModelIndex
这是我的QAbstractItemModel
子类的相关部分:
class PropertyItemModel(QtCore.QAbstractItemModel):
def __init__(self, parent=None):
super(PropertyItemModel, self).__init__(parent)
def setData(self, index, value, role=Qt.EditRole):
if role != Qt.EditRole:
return False
item = self.getItem(index)
result = item.setData(index.column(), value)
if result:
self.dataChanged.emit(index, index)
# Doesn't work either (same error):
# self.emit(QtCore.SIGNAL("dataChanged(QModelIndex, QModelIndex)"), index, index)
# QtCore.QObject.emit(self, QtCore.SIGNAL("dataChanged(const QModelIndex&, const QModelIndex&)"), index, index)
return result
我在 Mac OS X (10.10) 上使用 PySide 1.2.1 版和 Qt 4.8.5。该错误可能与我的特定环境有关。此代码在另一台 Mac 上运行。