[PyQt] a subclass for a c++ object
Blaine Bell
blaine.bell at schrodinger.com
Sat Jun 26 18:06:51 BST 2010
Ah, I see. That is a very interesting problem. I would think that it
could be solved by using pointers to member functions, but upon reading
up on those, it seems like it could be difficult to figure out whether
the subclass has implemented that function (the way member functions are
implemented could be compiler dependent as well).
Another way of potentially solving this issue would be to generate a
boolean member variable that detects whether the SIP's class function
has already been called (to avoid the recursion problem). I think this
would take into account the issue where the base function might call the
same function, since its the same object, it would either always have a
base function or not.
This could be a good enhancement for SIP (i.e., to add a boolean member
variable for each member function, then check it before the subclass
function is called).
I think having to implement all functions in SIP that are used in C++
has weird dependency issues. If a programmer is working in just c++,
they can break the SIP implementation without knowing it.
I would like to know what you think. This enhancement could also be an
option for class implementations if you feel it is a significant
performance hit (it could be). It could also be taken out for functions
that are used quite a bit (using Annotations in SIP)
Thanks for your quick response! Its could to know how this works.
Blaine
> SIP will generate a C++ reimplementation of flags() that works out if there
> is a Python reimplementation and calls it if so.
>
> If there is no Python version then it explicitly calls the most specific
> C++ implementation that it knows about. It has to explicitly call it (i.e.
> with an explicit scope) to avoid recursion. If you haven't told it about a
> more specific version (because it doesn't appear in the corresponding .sip
> file) then it can never be called.
>
> Phil
>
More information about the PyQt
mailing list