QList<QGraphicsItem*>::iterator it = m_scene->items().begin(); bool _b = false; for (; it != m_scene->items().end(); ++it) { _b = !_b; QGraphicsItem* _item = *it; Chip* _chip = dynamic_cast<Chip*>(_item);// Chip* _chip = static_cast<Chip*>(_item); if(_b) _chip->changeColor(); else _chip->restoreColor(); }
void Chip::changeColor(){ m_even = true;}
class CustomItem : public QGraphicsItem { ... [b]enum { Type = UserType + 1 };[/b] [b]int [/b]type() const { // Enable the use of qgraphicsitem_cast with this item. return Type; } ... };
undefined reference to vtable
QGraphicsItem* _item = *it;Chip* _chip = qobject_cast<Chip*>(_item);
QList<QGraphicsItem*> _all; _all = m_scene->items(); foreach (QGraphicsItem *item, _all) { Chip* _chip = qgraphicsitem_cast<Chip*>(item); if (_chip){ _chip->changeColor(); } }
QList<QGraphicsItem*>::iterator it = m_scene->items().begin();
QList<QGraphicsItem*> theList = m_scene->items();QList<QGraphicsItem*>::iterator it = theList.begin();