[PyQt] Adding methods to C++-created objects
Phil Thompson
phil at riverbankcomputing.co.uk
Thu Oct 18 10:15:33 BST 2007
On Wednesday 17 October 2007, Giovanni Bajo wrote:
> On Wed, 2007-10-17 at 18:18 +0100, Phil Thompson wrote:
> > > class MyDelegate(QItemDelegate):
> > > def createEditor(self, *args):
> > > ed = QItemDelegate.createEditor(self, *args)
> > > ed.foo = bar # adding stuff to python instance
> > > ed.foo2 = lambda: bar
> > > return ed
> > >
> > > def setModelData(self, editor, model, index):
> > > print editor.foo # accessing python stuff added before
> > >
> > >
> > > I think it's either a PyQt bug or simply this usage pattern is not
> > > fully supported. If this is something that should work, I'll work on a
> > > repro recipe.
> >
> > It should work (assuming the parent argument to createEditor() is not
> > None/NULL).
> >
> > The qitemdelegate.sip file looks like it might be missing some
> > annotations. The following may help...
> >
> > virtual QWidget *createEditor(QWidget *parent /TransferThis/,
> > ...) const /Factory/;
>
> This fixed it, thanks!
Should be fixed in tonight's snapshot.
Phil
More information about the PyQt
mailing list