Qt-interest Archive, October 2007
Dynamic cast QGraphicsTextItem
Message 1 in thread
Hi,
When I try to dynamic_cast a QGraphicsItem to QGraohicsTextItem,
I get the following error :-
__non_rtti_object
Any idea what is going on here ?
R's
Prateek
Message 2 in thread
Prateek Tiwari wrote:
> Hi,
>
> When I try to dynamic_cast a QGraphicsItem to QGraohicsTextItem,
> I get the following error :-
>
> __non_rtti_object
>
> Any idea what is going on here ?
You need RTTI in order to use dynamic_cast:
http://en.wikipedia.org/wiki/Dynamic_cast
--
[ signature omitted ]
Message 3 in thread
Bjoern Erik Nilsen wrote:
> Prateek Tiwari wrote:
>> Hi,
>>
>> When I try to dynamic_cast a QGraphicsItem to QGraohicsTextItem,
>> I get the following error :-
>>
>> __non_rtti_object
>>
>> Any idea what is going on here ?
>
> You need RTTI in order to use dynamic_cast:
>
> http://en.wikipedia.org/wiki/Dynamic_cast
An easy solution would be to use multiple inheritance from QGraphicsItem
and QObject and then use qobject_cast :-)
--
[ signature omitted ]
Message 4 in thread
But then shouldn't this be a consistent behaviour ?
I am using VS 2003.
I am able to use dynamic_cast for other QGraphicsItems such as
QGraphicsRectItem.
This looks wierd :(
--Prateek
-----Original Message-----
From: Bjoern Erik Nilsen [mailto:bnilsen@xxxxxxxxxxxxx]
Sent: Thursday, October 18, 2007 5:09 PM
To: qt-interest@xxxxxxxxxxxxx
Subject: Re: Dynamic cast QGraphicsTextItem
Bjoern Erik Nilsen wrote:
> Prateek Tiwari wrote:
>> Hi,
>>
>> When I try to dynamic_cast a QGraphicsItem to QGraohicsTextItem, I
>> get the following error :-
>>
>> __non_rtti_object
>>
>> Any idea what is going on here ?
>
> You need RTTI in order to use dynamic_cast:
>
> http://en.wikipedia.org/wiki/Dynamic_cast
An easy solution would be to use multiple inheritance from QGraphicsItem
and QObject and then use qobject_cast :-)
--
[ signature omitted ]
Message 5 in thread
I recompiled my application and it works fine!
Sorry for the inconvinience!
--Prateek
-----Original Message-----
From: Prateek Tiwari [mailto:ptiwari@xxxxxxxxxxx]
Sent: Thursday, October 18, 2007 5:11 PM
To: bnilsen@xxxxxxxxxxxxx; qt-interest@xxxxxxxxxxxxx
Subject: RE: Dynamic cast QGraphicsTextItem
But then shouldn't this be a consistent behaviour ?
I am using VS 2003.
I am able to use dynamic_cast for other QGraphicsItems such as
QGraphicsRectItem.
This looks wierd :(
--Prateek
-----Original Message-----
From: Bjoern Erik Nilsen [mailto:bnilsen@xxxxxxxxxxxxx]
Sent: Thursday, October 18, 2007 5:09 PM
To: qt-interest@xxxxxxxxxxxxx
Subject: Re: Dynamic cast QGraphicsTextItem
Bjoern Erik Nilsen wrote:
> Prateek Tiwari wrote:
>> Hi,
>>
>> When I try to dynamic_cast a QGraphicsItem to QGraohicsTextItem, I
>> get the following error :-
>>
>> __non_rtti_object
>>
>> Any idea what is going on here ?
>
> You need RTTI in order to use dynamic_cast:
>
> http://en.wikipedia.org/wiki/Dynamic_cast
An easy solution would be to use multiple inheritance from QGraphicsItem
and QObject and then use qobject_cast :-)
--
[ signature omitted ]