[PyKDE] Using PyQt in my .sip file leads to several problems

Phil Thompson phil at river-bank.demon.co.uk
Thu Aug 8 15:24:00 BST 2002


Sergey ANIKIN wrote:

> Domain: Linux  C++  Qt-2.2.2 PyQt-3.3.2 sip-3.3.2
> 
> I'm trying to write a small C++ class with one method retuning the 
> desktop widget for my application.
> I would like my method to be called from Python script to use the widget 
> returned as a parent for PyQt dialogs.
> I do the following:
> 
> //   desktop.h:
> 
> #include <qwidget.h>
> class Desktop
> {
>    public:
>        static QWidget* getDesktop();
> };
> 
> // desktop.cxx:
> 
> #include <qapplication.h>
> QWidget* Desktop::getDesktop()
> {
>    return qApp::desktop();
> }
> 
> // desktop.sip:
> 
> %Module Desktop
> 
> # FIRST PROBLEM: I had to include almost all PyQt .sip files here in 
> order to make SIP work without errors. Otherwise, it reports "QWidget is 
> not defined", etc.
> # Is it right?
> %Include versions.sip
> %Include qglobal.sip
> ...
> %Include qwidget.sip


Don't %Include any of the PyQt .sip file. Instead...

%Import qtmod.sip

Take a look at how the other PyQt modules (eg. qtcanvasmod.sip) work.

Phil




More information about the PyQt mailing list