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

List:       pykde
Subject:    Re: [PyQt] Construct QVariant from object of user type
From:       "Arve Knudsen" <arve.knudsen () gmail ! com>
Date:       2008-04-27 14:31:47
Message-ID: a0d6258d0804270731p4e1df6d2j5051f31669f2ddf0 () mail ! gmail ! com
[Download RAW message or body]

On Sun, Apr 27, 2008 at 4:25 PM, Phil Thompson
<phil@riverbankcomputing.com> wrote:
>
> On Saturday 26 April 2008, Arve Knudsen wrote:
>  > On Sat, Apr 26, 2008 at 10:43 AM, Phil Thompson
>  >
>  > <phil@riverbankcomputing.com> wrote:
>  > > On Friday 25 April 2008, Arve Knudsen wrote:
>  > >  > On Thu, Apr 24, 2008 at 5:55 PM, Phil Thompson
>  > >  >
>  > >  > <phil@riverbankcomputing.com> wrote:
>  > >  > > Tonight's PyQt snapshot will have some support for storing a Python
>  > >  > > object in a QVariant so the following code works...
>  > >  > >
>  > >  > >  from PyQt4.QtCore import QVariant
>  > >  > >
>  > >  > >  class Klass(object): pass
>  > >  > >
>  > >  > >  k = Klass()
>  > >  > >  v = QVariant(k)
>  > >  > >  v1 = QVariant(v)
>  > >  > >  assert v1.toPyObject() is k
>  > >  > >
>  > >  > >  Let me know if more is needed.
>  > >  >
>  > >  > I'm missing a way to specify the QVariant::Type for such an object.
>  > >
>  > >  Why would you want to give each Python type a different metatype?
>  >
>  > Because of my original case, to be able to work with
>  > QItemEditorFactory, which parameterizes on QVariant::Type (see
>  > QItemEditorFactory::registerEditor).
>
>  Tonight's snapshot...
>
>  The QVariant() ctor will now register new Python types automatically. I've
>  also wrapped QMetaType.type() and overloaded it so that you can pass a Python
>  type. I think this is enough for what you need.

Sounds like it should be enough. Thanks!

Arve
_______________________________________________
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