我创建了一个类Atom
扩展了Qt类QGraphicsItem
这样的:Qt的添加扩展的QGraphicsItem场景
Atom::Atom(qreal rad, qreal mass, int element, int state) : QGraphicsItem()
{
// Initialization code
}
void Atom::changeState(int newState)
{
// Code...
}
然后,我在我的原子添加到场景是这样的:
Atom *a=new Atom(rad,mass,element,state);
a->setPos(pos);
scene->addItem(a);
但是,Qt将我的Atom类转换为QGraphicsItem类。现在,当我打电话给scene->items()
时,我得到了一个QGraphicsItems的QList,它没有我的Atom类的属性和方法。
所以,我问的问题:我将如何去获得我添加到我的QGraphicsScene的原子列表?
谢谢。
谢谢。 'dynamic_cast(item)'vs'((Atom *)item)有什么区别? –
Joel
2012-02-05 20:30:45
@Joel:http://stackoverflow.com/questions/28002/regular-cast-vs-static-cast-vs-dynamic-cast – Mat 2012-02-05 20:36:01
谢谢。我想我现在明白了。 – Joel 2012-02-05 20:42:23