Is the pixmap a scene item too?
Is the pixmap a scene item too?
The way it is setup, the QGraphicsItem displays the 'correct' pixmap depending on level of detail. Part of the function of 'MyGraphicsItem' is to initially draw itself onto a pixmap and then use the painter function QPainter::drawPixmap() in the QGraphicsItem::paint() function.
Btw, using Qt 4.6.2.
Can you calc the mid point of the source and then setPos on the pixmapItem?
Totally not tested (or compiled), but looks correct
Qt Code:
QVector2d vTopLeft(rect.topLeft()); pixmap->setPos(vMid->toPointF());To copy to clipboard, switch view to plain text mode
Last edited by pkohut; 4th January 2011 at 16:59.
spawn9997 (5th January 2011)
@pkohut I actually figured it out before I looked at this. I basically did exactly what you suggested. I forgot to set the new scaled Rectangle's center to the old Rectangle's center. The scaled rectangle is used to map points to the pixmap. I was mapping to a rectangle at the wrong position, Doh! When I called
and then mapped the points to this rectangle, everything looked exactly as it was supposed to.Qt Code:
tmp.moveCenter(m_realRect.center());To copy to clipboard, switch view to plain text mode
Bookmarks