PDA

View Full Version : Trying to use single pixmap in two Scenes.



spawn9997
4th August 2009, 19:59
I have generated a QPixmap and have added it to my main graphicsview via a subclass of QGraphicsScene.

What I want is to take that same pixmap and use it in my mini map (smaller graphicsview similar to the first). The smaller view uses the standard QGraphicsScene.

I have the Pixmap and have called QGraphicsPixmapItem *pixItem = scene->addPixmap(myPixmap);

Question will this alone scale the pixmap to properly fit in the scene?
How about the position? Should I need to map the pixmap's position or offset?

almost there but still needing help,


Spawn9997

spawn9997
5th August 2009, 22:23
Hey all,

Nevermind. My problem was not using one pixmap but trying to draw a QGraphicsPixmapItem in the scene where I wanted and at the correct size.
I decided to subclass the regular QGraphicsItem and attach a pixmap to it. Then draw that map in my reimplemented paint function. That way I could use the QGraphicsItem::boundingRect() as follows:


painter->drawPixmap(this->boundingRect().toRect(),*(this->pm));

where
this->pm is a pointer to my QPixmap.
This way the pixmap is forced to fit in my item. I just set the boundingRect() to the size of my scene. (minimap)


spawn9997
sw developer