[PyKDE] provide custom widget to python

Phil Thompson phil at riverbankcomputing.co.uk
Mon Dec 15 19:28:00 GMT 2003


On Monday 15 December 2003 12:18 pm, Jan Drugowitsch wrote:
> Hi everyone,
>
> I'm new to qt and have recently created my first custom widget (inherited
> from QScrollView) which works without any problems in C++ code. As I mainly
> use Python for the GUI work I'd like to provide this custom widget for use
> in python. As the sip documentation is pretty sparse and I'm not very
> 'informed' about the inner workings of Qt and how Python exactly handles
> its objects and garbage collection I still have problems achieving this.
>
> My .sip file declares the TokenDisplay class by inheriting QScollView. How
> do I get the reference to QScollView in there without including the whole
> qtmod.sip?
> That's the beginning of my .sip class declaration:
>
> class TokenDisplay : QScrollView
> {
> %HeaderCode
> #include "tokendisplay.h"
> %End
>
> public:
>     // enumeration for TokenClicked signal
>     enum MouseButton { RightButton, LeftButton };
>
>     TokenDisplay(QWidget* /TransferThis/ = 0, const char* = 0);
> [snip]
>
> Without including anything I get
> sip: QScrollView has not been defined
> If I include qtmod.sip, headers and wrappers for all the qt classes get
> generated and that's not what I want.
>
> Although I've searched through the mailing list I'm not much wiser than
> before. Does anyone have any cues I can start with? Sorry if this
> question's already been asked several times before.

%Import qtmod.sip

Phil




More information about the PyQt mailing list