[Qt-interest] Finding location of a QGraphicsItem that is in a QGraphicsItemGroup

Cole, Derek dcole at integrity-apps.com
Tue Jun 14 16:59:11 CEST 2011


I have a QGraphicsItemGroup that is layed out in a specific way, to make sure that the QGraphicsItem that compose it create a tiled version of a large image.


I am using a test like this

QList<QGraphicsItem *> groupItems =group->childItems();
while(!groupItems.isEmpty())
{
        Tile *tile = (Tile *)groupItems.first();
        QRectF itemRect = tile->mapRectFromScene(sceneRect);
        QRectF isec = itemRect.intersected(tile->boundingRect());
        if(isec.isEmpty())
            qDebug("Test was not visible!");
...
}

Is this the best way to test for which tiles are visible in the viewport? (Tile is a QGraphicsItem).

How can I find tile's position in the QGraphicsView?


I tried to use tile.pos() but it is not giving me the right answer. I think it might be because the QGraphicsItemGroup class I have created allows for scaling, and maybe that throws the positions off?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20110614/d17f69f9/attachment.html 


More information about the Qt-interest-old mailing list