[PyQt] PyQt4 question
Detlev Offenbach
detlev at die-offenbachs.de
Sat May 26 21:07:15 BST 2007
On Samstag, 26. Mai 2007, Phil Thompson wrote:
> On Saturday 26 May 2007 7:58 pm, Detlev Offenbach wrote:
> > On Samstag, 26. Mai 2007, Phil Thompson wrote:
> > > On Saturday 26 May 2007 4:52 pm, Detlev Offenbach wrote:
> > > > Hi,
> > > >
> > > > is there a PyQt equivalent to "qobject_cast<T*>(object)"?
> > >
> > > sip.cast()?
> > >
> > > But it shouldn't be necessary if the sub-class conversion code has been
> > > properly implemented.
> >
> > How do I do that. I haven't wrapped complicated stuff like this so far.
> > The situation is as follows. I have the following code:
> >
> > self.plugins.extend(self.designer.pluginManager().instances())
> > for plugin in self.plugins:
> > if isinstance(plugin, QDesignerFormEditorPluginInterface):
> > if not plugin.isInitialized():
> > plugin.initialze(self.designer)
> >
> >
> > "self.designer.pluginManager().instances()" returns a list of QObject.
> > The first if statement shall check, wether the returned QObject is of
> > type QDesignerFormEditorPluginInterface. In C++ you would do it with code
> > like
> >
> > if ( (qobject_cast<QDesignerFormEditorPluginInterface*>(plugin)) )
> >
> > How can the problem be solved with PyQt4 and Python?
> >
> > Note: self.designer.pluginManager() returns an object of type
> > QDesignerPluginManager.
>
> The wrapper for QDesignerFormEditorPluginInterface must define
> some %ConvertToSubClassCode which will use RTTI provided by the instance to
> identify the right Python type object. See how PyQt does it for QObject and
> QEvent. If the instance doesn't provide any RTTI then you're stuck.
>
Mustn't the %ConvertToSubClassCode go into the more general class (e.g.
QObject)? Is there a way to extend the QObject wrapper?
Detlev
--
Detlev Offenbach
detlev at die-offenbachs.de
More information about the PyQt
mailing list