[PyKDE] event type bug with sip-4-20031024?

Gerard Vermeulen gvermeul at grenoble.cnrs.fr
Mon Oct 27 08:32:01 GMT 2003


Hi Phil,

The SIP-4 API feels great and I can RECOMMEND sip-4 to newbies because
handwritten code is much easier to write.

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).

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 ). 




More information about the PyQt mailing list