[PyKDE] Recent convert's comments
phil at river-bank.demon.co.uk
Tue Jan 9 17:09:15 GMT 2001
Markus Stenberg wrote:
> On Tue, 9 Jan 2001, Phil Thompson wrote:
> > Markus Stenberg wrote:
> > >  PyQt (and SIP'd stuff in general) explodes _mysteriously_ if you try
> > > to do multiple inheritance. I understand the reasons behind this, but at
> > > least _I_ couldn't find any reference to it in PyQt documentation, and
> > > only way I realized the limitation was by browsing SIP-generated source
> > > code.
> > It's been on the TODO list for ages to detect when a programmer tries to
> > do this. I've added a statement to the docs saying not to do it.
> That works, I suppose (i.e. something like assertion if the class cannot
> be converted to desired class).
Actually I've just committed a change to SIP so that an exception is
raised if you try to do it.
> > > I wish there was way to support it as well, but guess it's possible to
> > > live without.. (although life's much more difficult - f.ex when
> > > implementing custom QSlider-type widget, I wished I could've inherited
> > > both QWidget and QRangeControl..)
> > It's impossible to support. You'd have to create a new C++ class (and
> > the binding to it) dynamically.
> How about having separate 'this' elements? I'm not sure if it would work,
> but I _think_ that by doing _sip_this_classname approach (and also doing
> it for all superclasses, i.e. _sip_QSlider would also have _sip_QWidget,
> _sip_QObject).. I'm not sure about the speed, but I don't think it'd be
> slower except at instantiation time.
It just wouldn't behave as you would expect. With multiple inheritance
you expect to end up with a single instance of a Qt class. What you are
suggesting is really composition trying to be inheritance. It would be
much better to be honest about it, inherit from one only and create an
instance of the second explicitly in the ctor.
More information about the PyQt