[SOLVED]Drawing a background with a pixmap and then drawing another pixmap on the background with QGraphicsItem
-
So here's what I want to do. I have a QGraphicsScene and I want to add a custom QGraphicsItem object to it. That QGraphicsItem is rectangle shaped. I want to add a .png picture as a background to that recangle and then I want to add another .png picture on that background. So, I use QPainter. Doing the background like this works
painter->setBrush(QBrush(QPixmap(":/pictures/background.png")));
but the problem is that the background.png picture is large and the rectangle is small, so only a small portion is painted to the rectangle shape. Is there a way to automatically resize/scale the .png picture, so it fits into the rectangle? Then the other issue. I'm trying to draw the second .png picture on the background like this:
painter->drawPixmap(0,0,30,30,QPixmap(":/pictures/figure.png"));
but once again, the picture is larger than the rectangle. The picture is mostly transparent, with an actual shaped picture in the middle, so I can't actually even see the picture being drawn on to the rectangle.
Am I in the right direction with what I want to do? Can I have the images automatically resized so that they fit into any shaped rectangle? Can I draw another pixmap in the background pixmap the way I described?
Edit:: That's indeed possible with the scaled function of QPixmap