How to Change the Background Color of QWidget
Jump to navigation
Jump to search
English | Deutsch | Български | 日本語 | Español | 简体中文| Persian
How to Change the Background Color of QWidget
QWidget [qt.io] is the base class of all user interface objects which means that the same approaches for changing the background color can be used with them too.
Using the Palette
The first example demonstrates how to change the background color using QPalette [qt.io]
Using Style Sheet
The style sheet contains a textual description of customizations to the widget’s style, as described in the Qt Style Sheets document [qt.io].
Both ways to change the background color of QWidget have been successfully built using Qt SDK 1.1 and tested on Symbian^3 devices.
Note: If you subclass a custom widget from QWidget, then in order to use the StyleSheets you need to provide a paintEvent to the custom widget :