[PyQt] How do I scale background image used in brush-palette?
mnations.lists at gmail.com
Tue Dec 23 17:32:11 GMT 2008
I am trying to place a background image in the main centralWidget of my app.
It will serve as the backdrop on which all of the other widgets will sit. A
simple change that will give it a much more professional appearance.
I have been able to achieve this by placing the image as a pixmap into a
brush and then inserting that into a palette:
brush = QtGui.QBrush(QtGui.QPixmap("Images/bluebg.jpg"))
palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Background, brush)
This doesn't scale the picture to be the same size as the centralWidget and
displays the picture as its natural size. This works as long as the picture
is larger than the application. I then tried to scale the picture with the
This turns the image into wallpaper, which I guess is working as intended
since the Texture function is designed to apply the texture in wallpaper
format. The problem is there doesn't appear to be an option to set the
Texture to just display the image.
Is there a way to scale the image so that it assumes the size of the target
widget, or should be approaching this in a different manner?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the PyQt