[PyQt] Re: About setting a pixmap as background

David Boddie david at boddie.org.uk
Fri Aug 3 00:26:46 BST 2007


On Thu Aug 2 14:50:11 BST 2007, Gustavo A. Díaz wrote:

> Anyone with a Tip for me with this? :$
> 
> Anyway, i am still trying to figure out how to do it, and i was reading
> about stylesheets which i saw is a little more easy to implement a own style
> for an app than using QStyle.

You don't need to use QStyle for this. To set a background pixmap, just
load a pixmap, create a brush that uses the pixmap as a texture, set the
appropriate palette role, and set the palette on the widget:

 widget = QWidget() # for example
 palette = widget.palette() # let's use the original palette
 pixmap = QPixmap(image_path)
 brush = QBrush()
 brush.setTexture(pixmap)
 palette.setBrush(QPalette.Background, brush)
 widget.setPalette(palette) # apply the modified palette to the widget

> And like i said in my last post, how to set transparency on an app?

See http://doc.trolltech.com/4.3/qwidget.html#windowOpacity-prop for
some ideas.

David



More information about the PyQt mailing list