[PyQt] Type map for python to Qt?
Russell Warren
russ at perspexis.com
Thu Feb 2 12:39:52 GMT 2017
Is there a table somewhere that indicates how PyQt handles mapping between
python types to Qt/C++ types? I can't find one.
Introspecting a random selection of some python types is extremely
informative:
>>> from PyQt5.QtCore import QVariant
>>> import datetime
>>> dt = datetime.datetime(2017,1,1)
>>> for x in ("a", b"b", 1, 1.1, [], [1], (1,), {}, {'a': 1}, {1:2}, None,
True, set(), dt):
... print("%-20r : %s" % (x, QVariant(x).typeName()))
...
'a' : QString
b'b' : PyQt_PyObject
1 : int
1.1 : double
[] : QVariantList
[1] : QVariantList
(1,) : PyQt_PyObject
{} : QVariantMap
{'a': 1} : QVariantMap
{1: 2} : PyQt_PyObject
None : None
True : bool
set() : PyQt_PyObject
datetime.datetime(2017, 1, 1, 0, 0) : PyQt_PyObject
Does that table exist anywhere?
Also of interest (not a bug report or complaint) is the apparent lack of
automatic type conversion for bytes, tuples, and datetimes, as well as the
recognition of non-string dict keys.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20170202/e42b1271/attachment.html>
More information about the PyQt
mailing list