[PyQt] Setting an image as background in QListView

absk82 absk82 at gmail.com
Fri Nov 19 21:57:21 GMT 2010

I have been having some trouble setting the background image in a QListView
using style sheets. I tried using both jpg as well as png images as
background. This is the stylesheet entry generated  by QtDesigner.
"    background-image: url(:/icons/images/wood_texture_png.png);\n"

After setting the image as background in QtDesigner, the image shows up
correctly in QtDesigner(as well as in the preview), but when I convert it to
python file (through pyuic4) and plug it into the other parts of the ode,
the background turns out to be white.  If I set the background as
QLinearGradient (as below)

background: qlineargradient(spread:pad, x1:0, y1:0, x2:1, y2:0, stop:0
rgba(128, 128, 128, 255), stop:1 rgba(255, 255, 255, 255));

then the background shows up properly even in my program. 

Does anyone know why this discrepancy could be there? 

In Qt, I noticed that there are functions like SetPaletteBackgroundPixmap(),
which could be used, but no there. Does anyone know if there is any other
way to set the background image in QListView?

Thanks a lot!
View this message in context: http://old.nabble.com/Setting-an-image-as-background-in-QListView-tp30260754p30260754.html
Sent from the PyQt mailing list archive at Nabble.com.

More information about the PyQt mailing list