On Mon, 1 Nov 2010 17:26:41 -0700, Qin Shen <jeans...@tippett.com> wrote: > Hi, > > In my non-template base class' .sip file, I used %ConvertToSubClassCode > directive > to downcast the base class type to its sub-class. If the sub-class is > not a template, > it all works fine. Now I need to derive a template sub-class from the > base class, > the sipFindType() won't work because there isn't any Python class > implemented > for the templated sub-class. What should I do in this case? > > > The files look like this: > > In [BaseEntity.sip] > -------------------------------------------- > class BaseEntity > { > %TypeHeaderCode > #include <BaseEntity.h> > %End > > %ConvertToSubClassCode > sipType = sipFindType(sipCpp->classType()); > %End > > public: > .... > > } > > > > [CustomEntity.h] > ------------------------------------------- > template <int ID> > class CustomEntity : BaseEntity > { > public: > CustomEntity(); > virtual ~CustomEntity(); > > std::string classType() const > { > std::ostringstream nameStream; > nameStream << "CustomEntity" << std::setfill('0') << > std::setw(2) << ID; > return nameStream.str(); > } > > ... // more stuff here > } > > > [CustomEntity.sip] > ------------------------------------------- > template <ID> > class CustomEntity : BaseEntity > { > %TypeHeaderCode > #include <CustomEntity.h> > %End > > public: > CustomEntity(); > virtual ~CustomEntity(); > > std::string classType() const; > > ... // more stuff here > }
So how is the template sub-class implemented in Python? Your %ConvertToSubClassCode will need to explicitly check for the template sub-class and return the appropriate Python type. Phil _______________________________________________ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt