[PyQt] %ConvertToSubClassCode across modules

Kevin Watters kevinwatters at gmail.com
Fri May 30 23:29:37 BST 2008


In the docs for %ConvertToSubClassCode, there's a mention about class
hierarchies over multiple modules:

>> Note that if a class hierarchy extends over a number of modules then
>> this directive should be used in each of those modules to handle the
>> part of the hierarchy defined in that module. SIP will ensure that
>> the different pieces of code are called in the right order to
>> determine the most specific Python type to use.

I've got this situation, but there's a small problem. Say MyObject is
defined in the main module, and has %ConvertToSubClassCode. Then in a
second module, I've got several objects that all inherit from MyObject.
They are all leaf nodes in the class hierarchy, so there's no common
base class in that other module to stick more %ConvertToSubClassCode
into.

Browsing through the PyQT sources, it looks like this case doesn't
happen, and there's always a common base class. (Oddly there's those
switch statements with hard coded integer constants checking against
sipCpp->type()--are those automatically generated? Or is it just relying
on the order classes are defined?)

But what can I do about this? It'd be nice to avoid some kind of runtime
RTTI list that the submodule appends to on startup, but if that's what
I have to do, that's alright ;) Just thought I'd check here first for
any ideas.

- Kevin



More information about the PyQt mailing list