[PyKDE] python/qt "slots" clash

Patrick Stinson patrickkidd.lists at gmail.com
Wed Jan 10 22:37:00 GMT 2007

There is a clash with the "slots" definition in (at least) python2.3
and the qt definition of "slots." Apparently this bug has been fixed
in a later version of python, but I would like to avoid an upgrade at
this point.

The problem is solvable if you

#undef slots

before including any qt headers in your C++ code. I have embedded the
python interpreter into my application, and included a bunch of sip
files to access my data structures from within my C++ executable.

My problem is that I am using precompiled headers and I include sip.h
then QtCore and QtGui, like this:

#include <sip.h>
#undef slots
#include <QtGui>
#include <QtCore>

...so slots gets redefined by the qt headers. when my sip*.cpp files
are compiled they include sip.h *then* my ModuleHeaderCode, and I get
the clash again. I am confused because sip.h should not be included
twice, so how is the clash comin back if the order is fixed in the

Here is the related python bug report:


Patrick Kidd Stinson

More information about the PyQt mailing list