Question

I am able to paint a pixmap by using QPainter::drawPixmap, but I am having trouble with the sizing. The pixmap is being drawn onto many different scenes. Some of the scenes are very large, and some are very small. This results in the pixmap drawn being either looking very large or very small, depending on the size of the scene (or viewport, whatever its called). I need the pixmap to look the same size everytime, regardless of the dimensions of the scene it is being placed into.

Basically, I want it to work similar to drawPoint, where you can specify the length and width of the point in pixels, so the point looks the same size every time.

The following line of code is inside my paint function of the QGraphicsItem I subclassed:

painter_p->drawPixmap( pos(), MYPIXMAP );

with pos() returning the QPointF I need to draw the pixmap at.

Was it helpful?

Solution

Can't you use QGraphicsPixmapItem? It'd do exactly what you want.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top