[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: Re: [PyQt] %ConvertToSubClassCode across modules
From: Gerard Vermeulen <gav451 () gmail ! com>
Date: 2008-05-31 9:24:27
Message-ID: 20080531112427.6715570d () jupiter ! rozan ! fr
[Download RAW message or body]
On Fri, 30 May 2008 23:41:57 +0100
Phil Thompson <phil@riverbankcomputing.com> wrote:
[ snip ]
> > 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.
>
> Your class (or your code) has to provide some form of RTTI. QEvent
> provides type(), QObject provides inherits().
>
You can also rely on the RTTI provided by the compiler (seems to not
always work on Windows). PyQwt has code like:
%If (CXX_DYNAMIC_CAST)
%ConvertToSubClassCode
// Walk the inheritance tree depth first in alphabetical order
// This code is for Qwt4 and Qwt5
#ifdef sipClass_QwtArrayData
if (dynamic_cast<const QwtArrayData *>(sipCpp))
sipClass = sipClass_QwtArrayData;
else
#endif
#ifdef sipClass_QwtDoublePointData
if (dynamic_cast<const QwtDoublePointData *>(sipCpp))
sipClass = sipClass_QwtDoublePointData;
else
#endif
#ifdef sipClass_QwtPolygonFData
if (dynamic_cast<const QwtPolygonFData *>(sipCpp))
sipClass = sipClass_QwtPolygonFData;
else
#endif
#ifdef sipClass_QwtData
if (dynamic_cast<const QwtData *>(sipCpp))
sipClass = sipClass_QwtData;
else
#endif
sipClass = 0;
%End
%End
Gerard
_______________________________________________
PyQt mailing list PyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic