[PyKDE] Re: event type bug with sip-4-20031024?
Phil Thompson
phil at riverbankcomputing.co.uk
Mon Oct 27 10:48:00 GMT 2003
On Monday 27 October 2003 7:31 am, Gerard Vermeulen wrote:
> Hi Phil,
>
> The SIP-4 API feels great and I can RECOMMEND sip-4 to newbies because
> handwritten code is much easier to write.
I'm most of the way through adding support for pointers and references to base
types (eg. int &) so you won't even need the handwritten code below.
> While adapting PyQwt for sip-4, I ran into the following warnings
> indicating that event handlers are getting objects of the wrong type:
>
> TypeError: argument 1 of QwtSlider.mouseDoubleClickEvent() has an invalid
> type TypeError: argument 1 of QwtSlider.mouseDoubleClickEvent() has an
> invalid type TypeError: argument 1 of QwtSlider.mouseDoubleClickEvent() has
> an invalid type TypeError: argument 1 of QwtSlider.keyPressEvent() has an
> invalid type TypeError: argument 1 of QwtSlider.keyPressEvent() has an
> invalid type TypeError: argument 1 of QwtSlider.keyPressEvent() has an
> invalid type TypeError: argument 1 of QwtSlider.keyPressEvent() has an
> invalid type TypeError: argument 1 of QwtSlider.keyPressEvent() has an
> invalid type
>
> And during some of the keyPressEvent()'s I moved the mouse (the events
> seem to be history dependent).
You mean the messages don't appear consistently? Can you see any pattern at
all.
I've noticed that, when running tut14.py and when either the shell is moving
or you drag the barrel of the cannon around you can sometimes get messages
about the underlying C++ object being deleted. The object is usually a QRect,
ie. a simple type (no virtual dtor) that's in existence for a very short
period of time.
I don't know if the two things are related.
> The class hierarchy looks like this (sorry this is a hopeless bug-report;
> I can make a mini-PyQwt-4.0 tonight, if you need it):
>
> class QwtSliderBase: QWidget, QwtDblRange
> {
> ...
> signals:
> void valueChanged(double);
> void sliderPressed();
> void sliderReleased();
> void sliderMoved(double);
>
> protected:
> void setPosition(const QPoint &);
> virtual void valueChange();
>
> virtual void timerEvent(QTimerEvent *);
> virtual void mousePressEvent(QMouseEvent *);
> virtual void mouseReleaseEvent(QMouseEvent *);
> virtual void mouseMoveEvent(QMouseEvent *);
> virtual void keyPressEvent(QKeyEvent *);
> virtual void wheelEvent(QWheelEvent *);
>
> virtual double getValue(const QPoint &) = 0;
> virtual SIP_PYTUPLE getScrollMode(const QPoint &) = 0 [void (const
> QPoint &, int &, int &)];
> // see 'virtual State QValidator::validate(QString &, int &) = 0;'
> // see 'virtual void getButtonShift(int &, int &) = 0;
> %MethodCode
> // The Python interface takes a QPoint and returns a tuple.
> int scrollMode;
> int direction;
>
> Py_BEGIN_ALLOW_THREADS
> sipCpp->getScrollMode(*a0, scrollMode, direction);
> Py_END_ALLOW_THREADS
>
> sipRes = sipBuildResult(&sipIsErr, "(ii)", scrollMode, direction);
> %End
> %VirtualCatcherCode
> PyObject *result = sipCallMethod(&sipIsErr, sipMethod,
> "Mii", &a0, sipClass_QPoint, a1, a2);
>
> if (0 != result)
> sipParseResult(&sipIsErr, sipMethod, result, "(ii)", &a1, &a2);
> %End
> };
>
> class QwtSlider: QwtSliderBase, QwtScaleIf
> {
> ...
> protected:
> virtual double getValue(const QPoint &);
> /* virtual */ SIP_PYTUPLE getScrollMode(const QPoint &);
> %MethodCode
> // The Python interface takes a QPoint and returns a tuple.
> int scrollMode;
> int direction;
>
> Py_BEGIN_ALLOW_THREADS
> sipCpp->getScrollMode(*a0, scrollMode, direction);
> Py_END_ALLOW_THREADS
>
> sipRes = sipBuildResult(&sipIsErr, "(ii)", scrollMode, direction);
> %End
> ...
> };
>
> QwtScaleIf and QwtDoubleRange have no event related stuff.
>
> Gerard
>
> PS: I tried to check if it was related to your latest objmap.c change, and
> it does not seem to be the case ( but I do not understand why my printf
> tracing statements didn't print ).
Actually you code above looks wrong. As the handwritten code refers to
protected methods, you should say...
sipCpp -> sipProtect_getScrollMode(*a0, scrollMode, direction);
Phil
More information about the PyQt
mailing list