[PyQt] qvariant and python objects

Henning Schröder henning.schroeder at gmail.com
Tue Jun 24 17:52:46 BST 2008


On Mon, Jun 23, 2008 at 9:50 AM, Phil Thompson
<phil at 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.
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


More information about the PyQt mailing list