[PyKDE] ConvertToSubClassCode

Phil Thompson phil at riverbankcomputing.co.uk
Tue Nov 18 20:14:01 GMT 2003


On Tuesday 18 November 2003 7:35 am, Gerard Vermeulen wrote:
> Hi,
>
> My difficulties to translate this C++ idiom to Python:
>
> bool Plot::eventFilter(QObject *object, QEvent *e)
> {
>     if ( e->type() == QEvent::Resize )
>     {
>         const QSize &size = ((QResizeEvent *)e)->size();
>         if ( object == (QObject *)axis(yLeft) )  // HOW TO THIS IN PYTHON?
>         {
> 	// ...
>         }
>     }
>
>     return QwtPlot::eventFilter(object, e);
> }
>
> were due to the fact that I did not implement ConvertToSubClassCode for
> the Qwt widgets.  Therefore, the 'is' operator did not work as expected.
>
> Since Qwt is more of a bunch of widgets than a neat hierarchy like PyKDE,
> the most natural choice is to convert down from a QObject to a specific
> subclass.
>
> As far as I understand, the sipc module knows how to handle more than
> one "static  PyObject *sipSubClass_QObject(const QObject *sipCpp)" (as
> long as they are implemented in different modules), but sip does not
> support it.

I don't understand - sip does support it, look at qtable.sip or qcanvas.sip. 
Or am I missing something?

Phil




More information about the PyQt mailing list