[Qt-interest] Widget Background colours

phil prentice philp.cheer at talktalk.net
Mon Mar 9 18:56:54 CET 2009


Hi  I have been using QT for a while, but I am still very much a novice as 
most of the GUI's I have written have been very straightforward.  I have a 
couple of questions regarding back-ground colours of widgets.  I want nearly 
all of my widgets in an application to have a blue background.  Initially I 
thought that I would do...

app.palette().setColor(QPalette::Window,0xFF0000FF);

QPalette::Window role being the background colour.
Could not get this to work, so I tried 

Palette p = w.palette();
p.setColor(QPalette::Window,0xFF00FF00);
w.setPalette(z);

This worked a lot better...it changed the colours of all my child widgets to 
blue except for my QListWidgets which continued to have a backgrould of 
white.

My questions are:-
1. Why does the app palette not work?
2. How can I get my QList Widgets to change there background colour.
3. Finally I must apologize because this is probably a C++ question.  I assume 
that the above Palette p = ... code would produce a memory leak or does QT 
handle this automatically?

I really appreciate your help
Thanks
Phil



More information about the Qt-interest-old mailing list