[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: Re: [PyQt] Inconsistent behavior with multiple inheritance and ConvertToSubClassCode
From: Phil Thompson <phil () riverbankcomputing ! com>
Date: 2018-09-30 12:46:21
Message-ID: AD4CFA5C-63FD-411D-880D-492878B95C72 () riverbankcomputing ! com
[Download RAW message or body]
On 25 Sep 2018, at 8:10 am, Nyall Dawson <nyall.dawson@gmail.com> wrote:
>
> Hi list,
>
> I've been struggling for a while with some inconsistent behavior
> relating to ConvertToSubClassCode and a multiple inherited class.
>
> The definition currently looks something like:
>
>
> class LayoutItem : LayoutObject, QGraphicsRectItem
> {
> %TypeHeaderCode
> #include "layoutitem.h"
> #include "layoutitempicture.h"
> #include "layoutitemlabel.h"
> %End
> %ConvertToSubClassCode
> // the conversions have to be static, because they're using
> multiple inheritance
> // (seen in PyQt4 .sip files for some QGraphicsItem classes)
> switch ( sipCpp->type() )
> {
> case QGraphicsItem::UserType + 104:
> sipType = sipType_LayoutItemPicture;
> *sipCppRet = static_cast<LayoutItemPicture *>( sipCpp );
> break;
> case QGraphicsItem::UserType + 105:
> sipType = sipType_LayoutItemLabel;
> *sipCppRet = static_cast<LayoutItemLabel *>( sipCpp );
> break;
> default:
> sipType = 0;
> }
> %End
> public:
> ...
>
>
> While this... sometimes... works correctly, most often LayoutItem
> subclasses are not automatically cast to the subclass, and remain as
> LayoutItems only. Is the ConvertToSubClassCode incorrect here?
There is nothing obviously wrong. You probably need to put in debug statements to \
work out exactly what is happening.
Phil
_______________________________________________
PyQt mailing list PyQt@riverbankcomputing.com
https://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