[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] qvariant and python objects
From:       Phil Thompson <phil () riverbankcomputing ! com>
Date:       2008-06-24 17:19:54
Message-ID: d99852a6e611ef0bda5c548bcc566e94 () localhost
[Download RAW message or body]

On Tue, 24 Jun 2008 18:52:46 +0200, "Henning Schröder"
<henning.schroeder@gmail.com> wrote:
> On Mon, Jun 23, 2008 at 9:50 AM, Phil Thompson
> <phil@riverbankcomputing.com> wrote:
>> While QVariant knows how to copy an arbitrary Python object (which is
> just
>> reference count manipulation) it doesn't know how to serialise one.
> BTW, is this reference available anyhow to Python? And could I use
> sip.cast with this reference to convert the QVariant object?
> I totally misunderstood toPyObject and thought that this function
> would do this for me automatically for all types.

No, just for QVariants that wrap objects that can't be converted through
the other ctors.

> This would be needed for writing a generic property editor or if an
> object/widget (-pointer) is stored inside a QVariant.
> 
> Henning
> 
> 
> 
> from PyQt4.QtCore import *
> from PyQt4.QtGui import *
> 
> app = QApplication([])
> win = QLabel("Test", None)
> p = win.property("font")
> assert p.typeName() == "QFont"
> assert p.toPyObject() == NotImplemented

Longer term I'd rather get rid of QVariant entirely, but if you have any
specific suggestions...

Phil

_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic