Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 6

Qt-interest Archive, August 2006
QT4.2 QGraphicsItem::type() question


Message 1 in thread

So in 4.1 we used rtti(), now we use type().  The docs say that
the custom values need to be greater than 0x80000000 which,
when printed shows up as -2147483600 on my system (Fedora 5).

Since Im using this as an array offset its obviously blowing up.
My question is, how do I correctly use this?  Im confused as to
why the number is not what I expected.  

If Im somehow supposed to use the qgraphicsitem_cast() call,
can someone explain how?  Im lost with this one.

Thanks
Jeff


--
 [ signature omitted ] 

Message 2 in thread

On Monday 28 August 2006 23:54, Jeff Lacki wrote:
> So in 4.1 we used rtti(), now we use type().  The docs say that
> the custom values need to be greater than 0x80000000 which,
> when printed shows up as -2147483600 on my system (Fedora 5).
>
> Since Im using this as an array offset its obviously blowing up.
> My question is, how do I correctly use this?  Im confused as to
> why the number is not what I expected.

Since all values must be greater than 0x80000000, you should be able to use it 
as an index by unsetting the MSB (i.e. 0x80000000 & 0x7fffffff).  This way 
you should get a positive integer.  Alternatively, cast these to unsigned.

It might also be wise to use a QMap with the type() values as a key instead of 
an array indexed by them; I suspect it's more memory efficient.

> If Im somehow supposed to use the qgraphicsitem_cast() call,
> can someone explain how?  Im lost with this one.

Sorry, I can't comment on this part :-(.

> Thanks
> Jeff
>
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
> "unsubscribe" in the subject or the body. List archive and information:
> http://lists.trolltech.com/qt-interest/

Best,
Marc

-- 
 [ signature omitted ] 

Attachment: pgpAf4mMFtl81.pgp
Description: PGP signature


Message 3 in thread

Jeff Lacki wrote:
> So in 4.1 we used rtti(), now we use type().  The docs say that
> the custom values need to be greater than 0x80000000 which,
> when printed shows up as -2147483600 on my system (Fedora 5).

This has changed since the TP; the value is now 65535. You can use 65535
with the TP as well.

Andreas

-- 
 [ signature omitted ]