[PyQt] Re: About setting a pixmap as background

"Gustavo A. Dí­az" gustavo.diaz at gmail.com
Fri Aug 3 02:56:41 BST 2007


Hi David!

Thanks for you Tips.

I am afraid that didnt worked, i wrote:


         self.centralwidget = QtGui.QWidget()
         palette = self.centralwidget.palette()
         bgPixmap = QtGui.QPixmap(":/Pixmaps/pixmaps/oc_clientBg.svg")
         brush = QtGui.QBrush()
         brush.setTexture(bgPixmap)
         palette.setBrush(QPalette.Background, brush)
         self.centralwidget.setPalette(palette)

The app runs but no pixmap appears as BG and now debug error.


David Boddie escribió:
> 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
>
> _______________________________________________
> PyQt mailing list    PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
>   


-- 
/Gustavo A. Díaz/
*GDNet Projects*
www.gdnet.com.ar <http://www.gdnet.com.ar>
Gustavo A. Díaz
-------------- next part --------------
Skipped content of type multipart/related


More information about the PyQt mailing list