On Thu, Apr 15, 2010 at 12:49 PM, Richard Dale <[email protected]> wrote: > On Thursday 15 April 2010 04:32:08 pm you wrote: >> On 2010-04-15, Richard Dale wrote: >> > 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 >> >> I am not aware of PyQt supporting this. So if it were added to the PSEP >> it would be above and beyond PyQt compatibility (which is fine). But can >> you provide any real use cases to justify its inclusion? > I think QtDBus support was where it was needed in QtRuby. As PyQt doesn't > support QtDBus, and PySide doesn't either currently, then they don't have that > problem. I suppose it would be anywhere QVariants are being used in an api > that involves serialization, where a C++ 'int' would be different to a > 'ushort'. >
What about supporting both? If the user want this kind of precision he can use a QVariant explicitly; if not, the python object can be implicitly converted to the QVariant. -- Lauro Moura INdT - Instituto Nokia de Tecnologia _______________________________________________ PySide mailing list [email protected] http://lists.openbossa.org/listinfo/pyside
