[PyQt] QVariant.toPyObject semantics

Phil Thompson phil at riverbankcomputing.com
Fri Jan 9 18:02:06 GMT 2009


On Fri, 9 Jan 2009 18:50:14 +0100, Lorenzo Berni <lorenzo at lilik.it> wrote:
> Hi all, I've a question about QVariant toPyObject method.
> 
> I want to store a dict in a QVariant (i hate QVariant, but i need them  
> for QSettings and Qt.UserData in QListWidget...) i try to make an  
> interface for converting all the python types in qt types and store  
> the qt types in QVariants but it doesn't work on linux (on mac os x it  
> works fine). I decide to try the toPyObject method.
> 
> On linux, when i store a dict in a QVariant and i call the toPyObject  
> method it returns exactly the python types found in the stored dict.
> 
> In mac os x, with the same dict, when i try to retrieve it with the  
> toPyObject method it returns a dict with all the python strs (or  
> unicodes)  converted in QStrings and it converts when it can, all the  
> python types in qt types.
> 
> Why the same method has a different behaviour on Linux and Mac OS X?

It doesn't.

> Linux: PyQt 4.4.3 Qt 4.4.1 python 2.5.2
> 
> Mac OS X: PyQt 4.4.4 - Qt 4.4.3 python 2.5.1
> 
> Help are greatly appreciated :D

It has different behaviour in different versions of PyQt.

Phil


More information about the PyQt mailing list