[PyKDE] Using QSqlQuery + bindValue = TypeError ?

Hans-Peter Jansen hpj at urpla.net
Sun Feb 27 15:21:09 GMT 2005


On Sunday 27 February 2005 15:27, Phil Thompson wrote:
> On Sunday 27 February 2005 2:08 pm, Hans-Peter Jansen wrote:
> > On Sunday 27 February 2005 14:37, Jorge Godoy wrote:
> > > But I keep always getting the following error message:
> > >
> > >     query.bindValue(":senha", senhaNova)
> > > TypeError: argument 2 of QSqlQuery.bindValue() has an invalid
> > > type
> >
> > Try:
> >     query.bindValue(":senha", QVariant(senhaNova))
> >
> > Phil, Qt is able to cast such stuff automatically, IIRC. Why
> > can't PyQt do this for us, too?
>
> It could be implemented, but I don't think the benefits outweigh
> the added complexity.

Well, I can imagine that.

Btw: such problems also occur, when Qt wants a QBrush, and you want to 
give it a color, e.g.:

    def paintEvent(self, e):
        p = QPainter(self)
        p.fillRect(self.rect(), QBrush(Qt.black))

Qt seems to be able to cast a QColor to a QBrush in this case..

Maybe these cases deserve a little chapter for their own in the docs 
and an item in the sip wishlist.

Pete




More information about the PyQt mailing list