[PyQt] Re: Construct QVariant from object of user type

Akos Polster akos at pipacs.com
Wed Apr 16 18:41:17 BST 2008


I don't think you can construct a QVariant _of_ an arbitrary object, but 
you can store most objects in QVariants as pickled strings:

>>> a=[1,2,3,4]
>>> v=QtCore.QVariant(pickle.dumps(a))
>>> pickle.loads(str(v.toString()))
[1, 2, 3, 4]

This may or may not be what you are looking for...

  ~ Akos.


Arve Knudsen wrote:
> How do I construct a QVariant of an object of a non-Qt class?
> 
> Thanks,
> Arve



More information about the PyQt mailing list