[PyQt] Type map for python to Qt?

Cody Scott cody at perspexis.com
Thu Feb 2 19:31:22 GMT 2017

I wouldn't worry about breaking compatibility. I'd be surprised if people
are actually passing Python tuples to Qt, since they don't come across as a
list and it is easy enough to convert to a list before passing the value to
Qt. And surely if they do now come across as a list then that would be
better (though might require a small code change).

On Thu, Feb 2, 2017 at 12:12 PM, Phil Thompson <phil at riverbankcomputing.com>

> On 2 Feb 2017, at 5:02 pm, Russell Warren <russ at perspexis.com> wrote:
> >
> > Conversions are implemented only if there is a direct equivalent,
> everything else gets converted to a PyQt_PyObject. You could perhaps make
> the case for the date/time types.
> >
> > datetime definitely might be nice, but the one I'd more likely want to
> make a case for is tuples.  I'm having to make some changes to deal with
> that now.
> >
> > The issue is that if a dict is converted to a QVariant and sent to QML,
> any tuples in the dict hierarchy aren't getting converted properly since
> PyQt is leaving them as `PyQt_PyObject`, which QML obviously has no clue
> what to do with.  Right now I'm trying to determine the best way to deal
> with this... might require recursively searching such dicts for tuples and
> converting to lists prior to shipping to QML as a `QVariant`.  If PyQt
> converted tuples into `QVariantList` there would no need for this.
> >
> > Is there a reason tuples don't get translated to QVariantList, just like
> lists do? Immutability concerns, maybe?
> >
> > Also, fwiw, python `bytes` could also potentially translate to
> `QByteArray`.  Never used that (I'm fairly new to Qt), but it seems
> equivalent at least. It also isn't in the Qt->QML translation table [1], so
> is of less interest.
> The reason for both is that I want conversions to be symmetrical. I'm not
> sure why I want that, other than it feels right. In any event any sort of
> change would break compatibility.
> Phil
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> https://www.riverbankcomputing.com/mailman/listinfo/pyqt
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20170202/e31a3f68/attachment.html>

More information about the PyQt mailing list