[prev in list] [next in list] [prev in thread] [next in thread] 

List:       koffice-devel
Subject:    Re: C++ help, please...
From:       "Robert Knight" <robertknight () gmail ! com>
Date:       2006-05-29 22:49:31
Message-ID: 13ed09c00605291549r1881f10t519c145f46f3c765 () mail ! gmail ! com
[Download RAW message or body]

Hi Thomas,

Perhaps it would be an idea to introduce a new class (eg.
KoCanvasWidgetBase) which extends both QWidget and KoCanvasBase, and
have KWCanvas inherit that.  The setCanvas method can then require a
parameter of that new class type.

Having setCanvas accept only a KoCanvasBase parameter seems like a bad
idea because there is an implicit assumption that the implementor of
KoCanvasBase will also extend QWidget - which the compiler cannot
check at runtime.

Regards,
Robert.

On 29/05/06, Thomas Zander <zander@kde.org> wrote:
> I've been trying to fix this problem for too long; I must be missing
> something obvious.
>
> In Flake I have an interface for a canvas; the KoCanvasBase class.
> I have another class, with a KoCanvasView::setCanvas() method that will
> use the canvas in two ways; as a widget and it will talk to the object
> via the above interface.
>
> In KWord I have a KWCanvas which implements both:
> class KWCanvas : public QWidget, public KoCanvasBase
>
> I instantiate it and then pass it to the setCanvas call.  (done in the
> KWGUI class) Obviously I need to downcast it either to QWidget or to
> KoCanvasBase.
>
> In the setCanvas method I then do a dynamic_cast.
> Problem is that if I downcast to a KoCanvasBase the dynamic cast to a
> QWidget fails.
> Same problem; if I downcast to a QWidget the dynamic cast to a
> KoCanvasBase gives me a nullpointer.
>
> Anyone can restore the sanity by telling me WTF is going on? Or better;
> fix the sources in koffice svn ;)
> --
> Thomas Zander
>
>
> _______________________________________________
> koffice-devel mailing list
> koffice-devel@kde.org
> https://mail.kde.org/mailman/listinfo/koffice-devel
>
>
>
>
_______________________________________________
koffice-devel mailing list
koffice-devel@kde.org
https://mail.kde.org/mailman/listinfo/koffice-devel
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic