[C++-sig] pybindgen and PyQt
Andreas Eriksson
aeriksson at gmail.com
Thu Aug 21 14:32:00 CEST 2008
Thanks for the reply Gustavo.
>> does anyone know if pybindgen plays nicely with PyQt (which uses SIP
>> for wrapping)? Can C++ class wrapped with pybindgen be passed to PyQt?
>
> For one thing, I find it hard to believe that PyQt would have any API that
> accepts an arbitrary class. At most I would believe in PyQt accepting an
> arbitrary subclass of a well known C++ base class wrapped by PyQt. So I am
> guessing you mean pybindgen wrapping a subclass of a PyQt-wrapped class.
> That I'm afraid will not work.
Actually, it is the first scenario that I am after. Let me describe in
some detail what I am after (slightly simplified):
We have a C++ class that derives from the C++ Qt class QWidget. Lets
call it OwnWidget. Several Qt methods expects pointers to subclasses
of QWidget, such as QLayout::addWidget(QWidget*). Using the PyQt
bindings I can create a python QLayout object. Now, what I want to do
is create a pybindgen wrapped OwnWidget instance and pass it to the
addWidget method of the PyQt QLayout object.
The following pseudo-code illustrates what I want to do. I tried it
using boost.python but without any luck.
C++:
#include <qt/QWidget.h>
class OwnWidget : public QWidget { ... }
python:
import pyqt
import ownwidget # wrapped using pybindgen
myWidget = ownwidget.OwnWidget()
layout = pyqt.QLayout()
layout.addWidget(myWidget)
Regards,
Andreas
More information about the Cplusplus-sig
mailing list