[PyKDE] Re: python/qt "slots" clash

Phil Thompson phil at riverbankcomputing.co.uk
Tue Jan 16 12:22:19 GMT 2007


On Wednesday 10 January 2007 10:55 pm, Patrick Stinson wrote:
> sorry for the double-post, but FYI adding
>
> #undef slots
>
> to the top of all of the sip*.cpp makes that file compile just fine.
> This is not a solution though because those files are auto-generated
> by sip...
>
> On 1/10/07, Patrick Stinson <patrickkidd.lists at gmail.com> wrote:
> > 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
> > pch?
> >
> >
> > Here is the related python bug report:
> >
> > http://www.google.com/url?sa=t&ct=res&cd=1&url=http%3A%2F%2Fmail.python.o
> >rg%2Fpipermail%2Fpython-bugs-list%2F2005-September%2F030473.html&ei=gmqlRY
> >vGHaaygwPmk_j3CQ&usg=__hJynaNrnzniof4fKXQdZHJxA5N4=&sig2=9B34igyhUw06q8BU6
> >HjrNw

Does putting the #undef slots before the include of Python.h in sip.h also 
work?

Phil




More information about the PyQt mailing list