[C++-sig] pyste and virtual classes.

Giulio Eulisse giulio.eulisse at cern.ch
Mon Mar 31 18:34:37 CEST 2003


> I can understand that, but I am having a hard time understanding what
> the use-case for such an arrangement is.  The C++ class designer
> explicitly said "you can't instantiate a class unless you implement
> this function".  Now you want to subvert that, in some sense.  Is the
> result really useful?

I understand what you mean and I would generally agree with what you
say.
The point is that in my case I cannot modify the library in question
(QT) and at the same time I would like to have a working (although very
limited) python module to see if what I want to do works or not.
Because of the complexity of QT I have to remove some pure virtual
methods because otherwise I would end up implementing bindings for the
whole library.
So I'm not saying that it would be really useful or a good coding
practice but, at least for me, it would be nice to have, for prototyping
and experimenting, just like the "exclude all that contains xyz"
feature.
Another possible solution would be get rid of the whole boost/QT idea,
and make PyQT and boost play nicely together(and play nicely with an
existing QApplication object). The problem is that I have to do the
following:

I have a virtual class "Base", which derives from a QT one, this class
gets derived into "Derived" and extended in python. An instance of the 
class "Derived" is created in an embedded python environment and is
passed to C++ using something like extract<Base&>. The virtual method
MyBase.method() is then called in C++ and its python implementation in
Derived gets called. Both the C++ and the Python environment need to
access the QT part of the class, and I don't want (better: I have not
to) to write wrappers around all the QT functions I need. I haven't
figured out how to do the extract<Base&> part when using PyQt. Maybe you
can help me?

Ciao,
Giulio





More information about the Cplusplus-sig mailing list