On Thursday 15 April 2010 02:26:32 pm Mark Summerfield wrote:
> No QString, or QVariant
> -----------------------
>
> The key difference between the APIs is that API 2 does not make QString
> or QVariant available to programmers, instead using Python 3's native
> str type for strings, and any Python class for QVariant.
Sometimes you need a C++ specific type wrapped in a QVariant to make a method
work correctly. For instance, the call might need a ushort type which has no
direct equivalent in Python . If you pass a Python integer it will be
converted to a QVariant with a C++ int wrapped inside it, and the call
expectng a ushort might not work.
So I think you need some way of forcing the correct sort of QVariant to be
created, probably by having a QVariant constructor where you pass a string
with the C++ type, along with the Python value as another argument. Or a tuple
of the type name string, followed by the python value that could be passed as
an argument everywhere a QVariant was expected.
If 'val' is an integer and we wanted a ushort based QVariant for the foo()
this won't work:
foo(val)
So it needs to be something like this instead:
foo(QVariant('ushort', val))
foo(('ushort', val))
-- Richard
_______________________________________________
PySide mailing list
[email protected]
http://lists.openbossa.org/listinfo/pyside