Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
[SOLVED]Drawing a background with a pixmap and then drawing another pixmap on the background with QGraphicsItem
qwhos last edited by
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
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:
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