Important: Please read the Qt Code of Conduct -

'list' object is not callable

  • Moving from PyQt to PySide, I'm noticing one of my views are spamming the error "TypeError: 'list' object is not callable". It seems the headers display normally, however the data method is not being executed and data is not displaying. Any insight appreciated.

    Qt 4.7.3
    PySide 1.1.0
    Python 2.7.3

    @from PySide import QtCore,QtGui

    class ScenarioOutputModel(QtCore.QAbstractItemModel):
    def init(self):
    self.headers = [] = []

    def add_rows(self,rows):
    def clear(self): = []
    def index(self,row,column,parent):
        """ Return index given a row, column, and parent index.
        param int row
        param int column
        param QModelIndex parent
        return int
        return self.createIndex(row, column, QtCore.QModelIndex())
    def getNode(self,index):
        """ Return node of corresponding index.
        param QModelIndex index
        return Node
        if index.isValid():
            node = index.internalPointer()
            if node is not None:
                return node
    def parent(self,index):
        """ Return parent index of given index.
        param QModelIndex index
        return QModelIndex
        return QtCore.QModelIndex()
    def flags(self,index):
        return QtCore.Qt.ItemIsEnabled|QtCore.Qt.ItemIsSelectable
    def set_headers(self,headers):
        self.headers = headers
    def headerData(self,section,orientation,role=QtCore.Qt.DisplayRole):
        if orientation == QtCore.Qt.Horizontal and role == QtCore.Qt.DisplayRole:
            return self.headers[section]
        return None
    def rowCount(self,index=QtCore.QModelIndex()):
        return len(
    def columnCount(self,index=QtCore.QModelIndex()):
        return len(self.headers)
    def data(self,index,role=QtCore.Qt.DisplayRole):
        if not index.isValid():
            return None
        if role == QtCore.Qt.DisplayRole:
            print 'data'
        return None

    if name == 'main':
    import sys
    app = QtGui.QApplication(sys.argv)

    table_view = QtGui.QTableView()
    model = ScenarioOutputModel()
    model.set_headers(['H%s'%s for s in range(10)])
    model.add_rows([[str(y) for y in range(10)] for x in range(10)])
    mw = QtGui.QMainWindow()


  • slap forehead

    Apparently naming a local variable the same as an method was tolerated somehow in pyqt. Renaming to something else relieved the issue.

  • Banned

    This post is deleted!

Log in to reply