[PyQt] Construct QVariant from object of user type
Arve Knudsen
arve.knudsen at gmail.com
Sat Apr 26 14:17:26 BST 2008
On Sat, Apr 26, 2008 at 10:43 AM, Phil Thompson
<phil at riverbankcomputing.com> wrote:
>
> On Friday 25 April 2008, Arve Knudsen wrote:
> > On Thu, Apr 24, 2008 at 5:55 PM, Phil Thompson
> >
> > <phil at 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).
Arve
More information about the PyQt
mailing list