[Qt-interest] Finding location of a QGraphicsItem that is in a QGraphicsItemGroup
Malyushytsky, Alex
alex at wai.com
Sat Jun 18 01:19:44 CEST 2011
I would suggest you to check how
QGraphicsItem::ensureVisible(...) and QGraphicsView::ensureVisible(...) work. QGraphicsView::ensureVisible does the check you need.
Alex
From: qt-interest-bounces+alex=wai.com at qt.nokia.com [mailto:qt-interest-bounces+alex=wai.com at qt.nokia.com] On Behalf Of Cole, Derek
Sent: Tuesday, June 14, 2011 7:59 AM
To: qt-interest at qt.nokia.com
Subject: [Qt-interest] Finding location of a QGraphicsItem that is in a QGraphicsItemGroup
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?
---------------------------------------------------------------------------------------------------
Weidlinger Associates, Inc. made the following annotations.
“This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you.”
“Please consider our environment before printing this email.”
More information about the Qt-interest-old
mailing list