[Kde-games-devel] kspaceduel: porting to Graphics View
Dmitry Suzdalev
dimsuz at gmail.com
Thu Dec 28 23:31:02 CET 2006
On Friday 29 December 2006 01:00, Henrique Pinto wrote:
> Either:
>
> foreach(QGraphicsItem *item, hitlist)
> {
> bullet = static_cast<BulletSprite*>(item);
> ...
> }
>
> or:
> foreach(BulletSprite *bullet, hitlist)
> {
> ...
> }
You forgot to note that this one will only work if hitlist is composed of
BulletSprite* ;-).
There's a third possibility:
You can use qgraphicsitem_cast instead of static_cast.
It should be faster, but you need to prepare you QGraphicsItem-inherited class
for its use.
See http://doc.trolltech.com/4.2/qgraphicsitem.html#qgraphicsitem_cast for
information on how to do that :-).
Cheers,
Dmitry.
More information about the kde-games-devel
mailing list