[PyKDE] SIP and typedefs in signals

Phil Thompson phil at riverbankcomputing.co.uk
Wed Dec 20 16:41:22 GMT 2006


On Monday 18 December 2006 7:34 pm, Gerard Vermeulen wrote:
> 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).

When does it crash? When you call connect()? When the signal is delivered?

> // 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?

I don't think that this is the problem. SIP supports the use of typedefs in 
signal arguments - see sipFindSigArgType() in siplib.c. As they are not used 
very much I think the problem is more likely to be a bug in that function.

Phil




More information about the PyQt mailing list