[PyQt] QAbstractTableModel problems in PyQt4

Vladimir Pouzanov farcaller at gmail.com
Mon Nov 5 09:48:45 GMT 2007


Hi all,

I'm trying to implement a table model:
class AModel(QtCore.QAbstractTableModel):
    def __init__(self, parent=None):
        QtCore.QAbstractTableModel.__init__(self, parent)
    
    def rowCount(self, parent=QtCore.QModelIndex()):
        print "row count rq"
        return 3
    
    def columnCount(self, parent=QtCore.QModelIndex()):
        print "col count rq"
        return 3
    
    def data(self, idx, role=QT.DisplayRole):
        print "data rq"
        return QtCore.QVariant("test")

...

self.ui.tableView.setModel(AModel())

the problem is that data is never called (rowCount/columnCount are called three
times each), so nothing is rendered. What do I mess?



More information about the PyQt mailing list