PDA

View Full Version : Problem with background



ale6111
2nd August 2010, 16:34
Hi,
I have a strange problem with an application, I set a background in this way:



QPalette palette;
palette.setBrush(QPalette::Window, QBrush(QImage("image.jpg")));
this->setPalette(palette);


I compiled on my pc and all work good.
Then I compiled on another pc and I get a black background.
If I set only a color as background in this way:


palette.setBrush(QPalette::Window, QBrush(Qt::cyan, Qt::SolidPattern));

all work good on both pc.
I thought a problem with path, but i try with absolute and I have the same result.
Both are linux system.
The first pc uses Qt version 4.6.2, GNOME and it's a 32 bit, the second uses Qt 4.6.3, KDE4 and it's a 64bit.
I really can't understand, help me.
Thanks.

tbscope
2nd August 2010, 16:45
The first thing I notice is this: jpg

Are you sure Qt can read jpg files on both pc's?

ale6111
2nd August 2010, 17:04
Honestly I don't know what libraries I need to look for...
I try to convert the image to .png and it doesn't work again, and in that application I have other .png for icon so I don't think is that the problem.


EDIT:
The problem seems to be this (http://www.qtcentre.org/threads/20566-Problem-in-setting-background-image-of-a-custom-widget) but it's old, in fact if I resize the widget for a short time I can see the image. I try the solution with stylesheet but since I have other widgets (ex. QTextEdit) the background is applied also on it, and I don't want.
And in any case why it works on first pc and not on second one. :confused: