[PyQt] PyQt4 question

Detlev Offenbach detlev at die-offenbachs.de
Sat May 26 19:58:23 BST 2007


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.

Detlev
-- 
Detlev Offenbach
detlev at die-offenbachs.de


More information about the PyQt mailing list