[Qt-interest] [SOLVED] Re: How to Map Back a QGraphicsItem by position ?
Aaron Lewis
aaron.lewis1989 at gmail.com
Mon May 10 12:49:30 CEST 2010
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 05/10/2010 12:41 PM, Ross Bencina wrote:
> Hi Aaron
>
> Once you've implemented type() you can use qgraphicsitem_cast<> to do a
> type-safe downcast, similar to the usual C++ dynamic_cast operator, it will
> return NULL if the cast fails.
>
> // YourItemType is a subclass of QGraphicsItem
>
> QGraphicsItem *graphicsItem = ?? // get a graphics item from somewhere
> YourItemType *item= qgraphicsitem_cast<YourItemType*>(graphicsItem);
> if(item)
> {
> // graphicsItem has type YourItemType, do something with it here.
> }
>
All Good for a safe cast , thanks Ross ;-)
- --
Best Regards,
Aaron Lewis - PGP: 0x4A6D32A0
FingerPrint EA63 26B2 6C52 72EA A4A5 EB6B BDFE 35B0 4A6D 32A0
irc: A4r0n on freenode
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAkvn5LoACgkQvf41sEptMqCyIwCfUBsCKoqPbXS98KarskOdl/LB
RFIAn0AvheByFgOag174I6TPwaVTsbhS
=zyd1
-----END PGP SIGNATURE-----
More information about the Qt-interest-old
mailing list