[PyKDE] SIP and typedefs in signals

Gerard Vermeulen gerard.vermeulen at grenoble.cnrs.fr
Mon Dec 18 19:34:37 GMT 2006


Hi,

moc does not expand typedefs in signals but sip does.
Therefore I needed a hack to wrap the following header code:

--- start C++ header code ---
typedef QPointF QwtDoublePoint;

class QWT_EXPORT QwtPlotPicker: public QwtPicker
{
    Q_OBJECT
    ...
signals:
    // Here, moc produces code containing QwtDoublePoint and not QPointF.
    void selected(const QwtDoublePoint &pos);
};
--- end C++ header code ---

--- start SIP declaration ---
// The C++ library declares
// typedef QPointF QwtDoublePoint;
// but that does not work in SIP (Python crashes, when using the typedef).
// However the following SIP declaration
class QwtDoublePoint: QPointF
{
%TypeHeaderCode
#include <qpoint.h>
%End // %TypeHeaderCode
};
// does work.

class QwtPlotPicker: QwtPicker
{
%TypeHeaderCode
#include <qwt_plot_picker.h>
%End // %TypeHeaderCode
    ...
signals:
    void selected(const QwtDoublePoint&);
    // void selected(const QRectF&); without typedef may have worked before,
    // but not with SIP-4.5.x.
};
--- end SIP declaration ---

Is it possible (or worthwhile) to make SIP behave like moc for such cases?


Gerard




More information about the PyQt mailing list