How to stretch background image used in brush-palette
I am trying to make a header label with text over a background image. I'm using the image like a spacer image, so it should stretch the width of the label. I have been able to get the image in the background; however I can't figure out how to make it stretch. Here is the code:
Code:
brush.
setTexture(QtGui.
QPixmap("Images/small_border.png"))brush.setStyle(QtCore.Qt.TexturePattern)
self.ui.label_2.setPalette(palette)
The image is being displayed in the TexturePattern, just as it should given the style. However I don't see a way to set the style so that it will stretch the image to fill the space. How can I do that?
Thanks
Re: How to stretch background image used in brush-palette
Re: How to stretch background image used in brush-palette
I think that only applies to objects in the foreground. It works like I want it to if I load a picture into the label. The problem is that I can't get any text on top of it at that point because you have to pick one or the other.
Re: How to stretch background image used in brush-palette
In that case, scale the pixmap to the label's size.
Code:
QPixmap pix
= QtGui.
QPixmap("Images/small_border.png").
scaled(label_2
->size
());
brush.setTexture(pix);
Somethign like that.. hope u get the idea
Re: How to stretch background image used in brush-palette
I didn't know you could scale it like that, so I tried to scale it against the main centralWidget to give it a full backdrop. It's a case where I believe it's working properly but not as desired.
When I scale it against the main frame it sizes it up properly to give a nice textured pattern of the image. However I can't find any way to make it not texture and just give me a solid image that is scaled to be the size of the widget.
If I don't specify the texture than it will display the image in it's natural size. So if I wanted to use a background picture I can just make it larger than most monitors can display it, and I have my background image.
However I've tried all kinds of ways but still can't find a way to make the image simply scale to the size of target widget. I've tried creating the brush with a pix image as the argument, but I guess it defaults to be a texture. Is putting an image into a Texture the only way to insert it into a brush, or is there any other way?
Re: How to stretch background image used in brush-palette
<bump> Is this functionality just not available in pyqt4?