[PyQt] QVariant and Python list

Phil Thompson phil at riverbankcomputing.com
Sun Jun 1 13:14:03 BST 2008


On Wednesday 28 May 2008 6:35:32 pm Laurent Léonard wrote:
> Hi,
>
> I read QList and QMap are not implemented in PyQt, because of the presence
> of Python lists and dictionaries.
>
> But how can I use QVariant to "encapsulate" Python lists and dictionaries ?
> When I try to do it I get the following error message : "TypeError:
> argument 1 of QVariant() has an invalid type"

Tonight's snapshot will make sure that all Python lists and dicts will be 
treated as Python objects by QVariant and retrievable with toPyObject().

I haven't gone as far as I had originally proposed (applying /Constrained/ 
throughout) as I think it will break too many things - particularly 
QVariant("am I a QString or a Python object?")

Phil



More information about the PyQt mailing list