So how can I identify the items making up the grid in a QGraphivcsView::resizeEvent()?
One way would be to simply use dynamic_cast
and QGrahpicsScene::items()
:
foreach( QGraphicsItem *item, myScene->items() )
{
GridItem *gridItem = dynamic_cast<GridItem*>( item );
if( gridItem )
{
// Apply appropriate transformation here
}
}
A slightly more "Qt" way to do the above would be to ensure your QGraphicsItem subclass reimplements QGraphicsItem::type()
foreach( QGraphicsItem *item, myScene->items() )
{
if( item->type() == GridItem::Type )
{
// Apply appropriate transformation here
}
}
Would it be possible to adjust the scene in a way that a given area
(sceneRect) is always filling the complete view?
QGraphicsView::fitInView() should do the trick
Also, while I'm not entirely sure what you're trying to accomplish, it sounds to me that you may want to check out the QGraphicsItem::ItemIgnoresTransformations
flag.
myItem->setFlag( QGraphicsItem::ItemIgnoresTransformations )
which makes it so that any item with the given flag will not be affected by changes in the zoom level.