[PyQt] subclassing QSqlTableModel
Pavel Brych
pavel at brych.cz
Fri Sep 23 12:43:59 BST 2011
Hi Paolo,
you must return your flags like this:
def flags(self, index):
return QSqlTableModel.flags(self, index)
Otherwise your method returns None.
Pavel
Dne 23.9.2011 13:28, paolo at paolodestefani.it napsal(a):
> I'm using python 3.2 and pyqt 4.8.5 on windows 7 32bit
> I'm trying to understand how subclassing QSqlTableModel works and i don't
> understand why this code fail:
>
> class StaffModel(QSqlTableModel):
> def __init__(self, parent):
> QSqlTableModel.__init__(self, parent)
> self.setTable("staff")
>
> def flags(self, index):
> QSqlTableModel.flags(self, index)
>
> I use this model in a tableview and what i get is this messages:
>
> TypeError: invalid result type from StaffModel.flags()
> TypeError: invalid result type from StaffModel.flags()
> TypeError: invalid result type from StaffModel.flags()
> TypeError: invalid result type from StaffModel.flags()
> (...)
>
> If i delete the flags() method, so that StaffModel is the same of
> QSqlTableModel but with 'preloaded' the table name, everything works as
> expected.
> Looks Like i can not redefine methods ?
>
> Thanks.
>
> Paolo
>
>
> _______________________________________________
> PyQt mailing list PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
--
Pavel Brych
=============================
tel: 721116063
mail: pavel at brych.cz
ICQ: 304482700
Jabber: pavel.brych at jabber.cz
Skype: pavel.brych
MSN: pavel at brych.cz
WWW: http://brych.cz
More information about the PyQt
mailing list