[C++-sig] Can boost.python and PyQt be used together?

David Abrahams dave at boost-consulting.com
Sat Dec 7 21:02:53 CET 2002

"Paul F. Kunz" <Paul_Kunz at SLAC.Stanford.EDU> writes:

>   I have some widgets which inherit from Qt and made them as Python
> extension module using boost.python (v2).   

So, in Python they're represented as Boost.Python extension instances
containing instances of your widget classes (?)

> Now another group wants to use them in their application built with
> PyQt which uses SIP to make the Python extension modules.  At first
> glance, it looks like this wouldn't work.  

If I understand you correctly, whether it would work or not depends on
how sophisticated SIP can be about unwrapping a Boost.Python extension
instance and retrieving the underlying C++ object. I doubt SIP has
this ability built-in, but it may be possible for you to add it.

> A simple test program cause Segmentation fault.

That doesn't prove much of course. Most simple test programs cause
Segmentation faults ;-)

>   Is it known that use of boost.python and SIP together doesn't
> work?  

I have no such knowledge.

> If they can be made to work, what is the magic?

Hard to say without knowing a lot more about SIP. 

It seems like there are two obvious approaches:

1. Get Boost.Python to wrap your objects in a way that SIP already

2. Get SIP to understand the way Boost.Python already wraps objects

                       David Abrahams
   dave at boost-consulting.com * http://www.boost-consulting.com
Boost support, enhancements, training, and commercial distribution

More information about the Cplusplus-sig mailing list