[Qt-interest] How to Map Back a QGraphicsItem by position ?
Ross Bencina
rossb-lists at audiomulch.com
Mon May 10 06:41:29 CEST 2010
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.
}
HTH
Ross.
----- Original Message -----
From: "Aaron Lewis" <aaron.lewis1989 at gmail.com>
To: <qt-interest at trolltech.com>
Sent: Monday, May 10, 2010 2:06 PM
Subject: [Qt-interest] How to Map Back a QGraphicsItem by position ?
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi,
> I have a QGraphicsScene , inside it there's lots of QGraphicsItem.
>
> I tried to create a custom class which inherit QGraphicsItem , and i
> re-implemented the type() function.
> By that way i'll be able to detect my Item type.
>
> But the problem is , how can i map it back to a QGraphicsItem from a
> specified position ?
>
> e.g I know at QPointF(200,300) , there's a item , i will use
> QPointF(200,300) to map my QGraphicsItem back and check type() function
> to know what kind of Item it is.
>
> Appreciate any of your help ;-)
>
> Thanks in advance !
>
>
> - --
> 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/
>
> iEYEARECAAYFAkvnhlYACgkQvf41sEptMqBANwCfbN0cNKw8+xohx1EALR6LQPBO
> I0UAoMXhAsmq0siXOkbvq+Z5GloWMZjk
> =DtQk
> -----END PGP SIGNATURE-----
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
More information about the Qt-interest-old
mailing list