Qt QGraphicsView one background image in the center

My QGraphicsViewelement is much larger than its background image, but I would like this background image to be drawn only once. Now all this is filled with this background image as many times as there is for him.

So, how can I get this background image to be drawn only once in the center of the view?

Here is the code I'm using now:

QPalette palette;
palette.setBrush(this->backgroundRole(),QBrush(*myImage));
this->setPalette(palette);

Thank you for your responses!

+3
source share
1 answer

QGraphicsViewdisplays the background in the function drawBackground(). By default, this fills the view rectangle with a background brush, giving the result you see.

drawBackground(), , , QGraphicsView.

, , QGraphicsPixmapItem Z .

+1

Source: https://habr.com/ru/post/1773975/


All Articles