[Interest] [Qt4-feedback] Background color for labels?

Konrad Rosenbaum konrad at silmor.de
Wed Jan 18 22:02:34 CET 2012


>  From: Carl Schumann <schumann at fnal.gov>
> I have been trying for a while now to change the background color for a
> label.   I have been playing with the example from the Blanchette and

> I can change the text color with <font ...>.  How should I change the
> background color please?   Specifically, I would like to change it to
> white from the default, which appears to be a light grey.  Thanks for
> any help.

Actually when you insert <font...> you switch the label from plain text mode 
into rich text (html) mode. The change of color is more or less incidental.

Have a look at the palette() and setPalette(...) methods of QWidget (parent 
class of QLabel). You may also have to make the label background opaque.

Palette: http://developer.qt.nokia.com/doc/qt-4.8/qwidget.html#palette-prop

QPalette: http://developer.qt.nokia.com/doc/qt-4.8/qpalette.html (look for 
the setColor method...)

Background: 
http://developer.qt.nokia.com/doc/qt-4.8/qwidget.html#autoFillBackground-
prop

I recommend you also go through more of the tutorials and examples...
http://developer.qt.nokia.com/doc/qt-4.8/how-to-learn-qt.html
http://developer.qt.nokia.com/doc/qt-4.8/widgets-tutorial.html



	Konrad
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120118/897771e7/attachment.sig>


More information about the Interest mailing list