I am new to modeling, and I am following this guide while checking the documentation, and I came across this small detail: The code tutorial, which can be downloaded here , has in the QAbstractItemModel class (here QAbstractListModel) the setData method, whose code is:
def setData(self, index, value, role = QtCore.Qt.EditRole): if role == QtCore.Qt.EditRole: row = index.row() color = QtGui.QColor(value) if color.isValid(): self.__colors[row] = color self.dataChanged.emit(index, index) return True return False
In accordance with the explanations in the tutorial and from what I understood from the documentation, if the function returns True, then the view is updated, if it returns false, nothing happens, but when I changed the code to:
def setData(self, index, value, role = QtCore.Qt.EditRole): if role == QtCore.Qt.EditRole: row = index.row() color = QtGui.QColor(value) if color.isValid(): self.__colors[row] = color self.dataChanged.emit(index, index) return False
I realized that the view is still updating if color.isValid (), even if the function returns False. Am I misunderstanding the return role in the setData method or is this an error?
For reference, I am using PySide 1.2.1, not PyQt4.