[PyKDE] KXMLGUIFactory.container()

Phil Thompson phil at river-bank.demon.co.uk
Sun Apr 13 22:15:00 BST 2003


On Sunday 13 April 2003 8:44 pm, Gordon Tyler wrote:
> On April 13, 2003 05:31 am, Phil Thompson wrote:
> > This is handled by providing SIP with %ConvertToSubClass code. PyQt
> > provides the code for all classes that are part of Qt. PyKDE should do
> > the same for the relevant classes of KDE.
>
> I don't find any use of %ConvertToSubClassCode in PyKDE.
>
> > In this case, if KXMLGUIFactory.container() is returning a QPopupMenu
> > then the existing PyQt support should be enough as only Qt widgets are
> > involved. If, instead, it is returning a KDE specific sub-class of
> > QPopupMenu, and PyKDE doesn't provide appropriate %ConvertToSubClass code
> > then it will return the base type, ie. QWidget.
>
> KXMLGUIFactory.container() looks like it can return instances of
> KMainWindow, KMenuBar, KPopupMenu, KToolBar, or KStatusBar. It gets them
> from a DOM-like structure created and owned by an instance of
> KXMLGUIBuilder.

That sound's like the problem then.

> I've been looking at the use of %ConvertToSubClassCode in PyQt and I'm
> struggling to understand how it works. Could you give an example for this
> situation?

I can't give an easier example than the ones in PyQt. You are defining a table 
of class names and the corresponding SIP generated data structure that 
represents the Python type. The table must be in alphabetical order of the 
class name as it is searched using bsearch().

> > Factory functions should also have the SIP /Factory/ tag.
>
> What determines whether a function is a factory function?

If it returns a new instance of a class, like a constructor. The tag is needed 
so that SIP knows that Python is responsible for calling the instance's 
destructor.

Phil




More information about the PyQt mailing list