Proc Proc - 18 days ago 7
C++ Question

Unable to read contents of QGraphicsScene

I'm having some issues with Qt with c++ and reading the contents of my scene, here is my current code:

foreach(QGraphicsItem* item, ui->graphicsView->scene()->items())
{
item->setVisible(false)
qDebug() << item->x();
}


Currently this code is able to set all the items in my scene to invisible which is great however the query for all the item coordinates returns a 0 for every item in the scene. I feel I have some stupid mistake with pointers but I'm lost here currently.

Thanks in advance.

Answer

if a item is invisible it will not be possible to query for coordinates, for all effects it's just like if it was removed from the scene.