Hello,
i'm new in QT and i'm having problems with QGraphicsItem and my suclassed "Item".
I have a QGraphicsView that contains a QGraphicsScene in which i'm inserting some items.
Those items are a subclass of QGraphicsItem and i have called it TestHoverItem (It contains some additional values).

If i try to get one of the object i have in the QGraphicsScene using the itemAt() function i have no problem (code below)
Qt Code:
  1. QGraphicsItem::mousePressEvent(e);
  2. QPoint point = e->scenePos().toPoint();
  3.  
  4. auto sceneTop = scene();
  5.  
  6. QGraphicsItem *item = sceneTop->itemAt(point.x(), point.y(),QTransform());
  7. TestHoverItem *hover = qgraphicsitem_cast<TestHoverItem *>(item);
  8. qDebug() << "Codice " << QString::number(hover->getCodice());
To copy to clipboard, switch view to plain text mode 

If i try to get all the objects from the QGraphicsScene using the items() function the application crashes

Qt Code:
  1. QList<QGraphicsItem *> items;
  2. items = sceneTop->items();
  3. qDebug() << "Numero items " + QString::number(items.size());
  4. //Fin qui tutto bene
  5. TestHoverItem * aa= new TestHoverItem();
  6. for(int i=0; i<items.size(); i++){
  7. aa =qgraphicsitem_cast<TestHoverItem *>(items[i]);
  8. qDebug() << "Codice: " +QString::number(aa->getCodice());
  9. }
To copy to clipboard, switch view to plain text mode 

Can someone explain me what i'm doing wrong?
Thank you for the time and , i hope , for the answers