[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyKDE] PyQt4's QVariant returns tuples?
From:       Andreas Pakulat <apaku () gmx ! de>
Date:       2005-12-27 20:18:26
Message-ID: 20051227201826.GA11458 () morpheus
[Download RAW message or body]

On 27.12.05 19:27:11, Phil Thompson wrote:
> On Tuesday 27 December 2005 7:01 pm, Andreas Pakulat wrote:
> > Hi,
> >
> > does somebody know why QVariant.to* returns tuples when asking for
> > simple datatypes, like int and double?
> >
> > AFAICS it returns the value and wether the conversion was successful, is
> > this intended behaviour? Documented somewhere? Should I always use
> >
> > variant.toInt()[0] to get to the int?
> >
> > To me it seems a bit inconsistent, some of the to* functions return only
> > the data, some return a tuple and it's definitely not like Qt itself
> > handles the to* functions.
> 
> If a C++ function returns multiple values (the return value and via a pointer 
> in this case) then they are returned as a tuple. It's always been like this 
> and is consistent.

Aha. And thinking about it a 2nd time it also makes sense...

> A more natural idiom to use is...
> 
>     value, ok = variant.toInt()

Right.

Andreas

-- 
It was all so different before everything changed.

_______________________________________________
PyKDE mailing list    PyKDE@mats.imk.fraunhofer.de
http://mats.imk.fraunhofer.de/mailman/listinfo/pykde
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic