Search code examples
c++qtqgraphicsitemqgraphicsscene

return custom QGraphicsItem by itemAt() or collidingItems()


I create my own class:

class myTile : public QGraphicsItem{}

I add these myTile in a QGraphicsScene. Every myTile has a value and a getter for the value. Now I want to get a myTile and read its value.

I tried collidingItems() and itemAt(), but the problem is: These two method can only return QGraphicsItem. The QGraphicsItem doesn't have my return value method in myTile. Is there a way to get a custom item?
Thank you in advance!


Solution

  • myTile *t = (myTile*)myScene->itemAt(i);
    t->myMethod();