[PyKDE] PyQt4's QVariant returns tuples?
apaku at gmx.de
Tue Dec 27 20:18:26 GMT 2005
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() 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()
It was all so different before everything changed.
More information about the PyQt