Based on the SO example here and the below output:
from PyQt4.QtCore import QVariant
data = {'key1': 123, 'key2': 456}
v = QVariant((data,))
v.toPyObject()[0]
>>> {'key2': 456, 'key1': 123}`
I try to accomplish this for pyqt5 but with partial success.
import sys
from PyQt5 import QtCore
from PyQt5.QtCore import QVariant
data = {'key1': 123, 'key2': 456}
v = QtCore.QVariant((data,))
v.value()[0]
print v
The output is:
<PyQt5.QtCore.QVariant object at 0x0000000006778748>
and not the expected:
{'key1': 123, 'key2': 456}
or{'key2': 456, 'key1': 123}
As the implementation of QVariant changed toPyObject()
was removed and received value()
instead in pyqt5. Any help on how to get the value instead of object location?