[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: Fwd: Re: [PyQt] QVariant conversion toInt()
From: Christoph Burgmer <chrislb () gmx ! de>
Date: 2008-07-27 11:55:34
Message-ID: 200807271355.35328.chrislb () gmx ! de
[Download RAW message or body]
For reference again now to the list, though this has been answered already.
---------- Weitergeleitete Nachricht ----------
Subject: Re: [PyQt] QVariant conversion toInt()
Date: Sonntag, 27. Juli 2008
From: Christoph Burgmer <chrislb@gmx.de>
To: larry@foxgulch.com
Am Sonntag, 27. Juli 2008 schrieb lj:
> Given this small snip:
>
> from PyQt4.QtCore import *
> from PyQt4.QtGui import *
>
> qv = QVariant(255)
> print qv.canConvert(QVariant.Int) #prints True, can be converted
> x = qv.toInt() # so attempt the conversion
> print type(x), x #prints <type 'tuple'> (255, True)
> # I expected <type int> and 255
>
> I supposed that x after conversion out of the variant object qv would be
> type Int and print x would result in 255 being printed but that
> doesn't happen.
>
> I must be missing something?
The documentation on QVariant reflects the different behaviour of PyQt in this
case [1], [2]:
(int, bool ok) toInt (self)
Chris
[1] http://doc.trolltech.com/4.4/qvariant.html
[2] http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qvariant.html
-------------------------------------------------------
_______________________________________________
PyQt mailing list PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic