[PyQt] QAbstractTableModel problems in PyQt4
    Phil Thompson 
    phil at riverbankcomputing.co.uk
       
    Mon Nov  5 10:18:57 GMT 2007
    
    
  
On Monday 05 November 2007, Vladimir Pouzanov wrote:
> 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?
Your model is being immediately garbage collected.
Phil
    
    
More information about the PyQt
mailing list