[PyQt] QVariant conversion toInt()

Andreas Pakulat apaku at gmx.de
Sun Jul 27 18:41:06 BST 2008


On 27.07.08 09:23:48, lj wrote:
> And furthermore I read where string can be converted to just
> about everything... except Point, Rect and Size so to check 
> I ran the script below.
> 
> qv = QVariant(QString("255"))   # qv contains QString "255"
> print "\n Expect False"
> print qv.canConvert(QVariant.Point)
> print qv.canConvert(QVariant.Rect)
> print qv.canConvert(QVariant.Size)
> 
> print "\n Expect True"
> print qv.canConvert(QVariant.Bool)
> print qv.canConvert(QVariant.ByteArray)
> print qv.canConvert(QVariant.Char)      #!!! Prints False !!!

Well, the string has a length larger than 1 so its not possible to
convert it into a single character without loosing data.

Andreas

-- 
Look afar and see the end from the beginning.


More information about the PyQt mailing list