Qt Snippet: Set background color of a widget

Is possible to easily set the background color of a widget by changing the palette of widget itself.

The code is very easy as follow:


// We set a white background color for this example
QPalette FramePalette(MyWidget->palette());
FramePalette.setColor(QPalette::Background, Qt::white);

Please note that for have our custom backgound color showed is need to set the setAutoFillBackground flag to true as the example.


Popular posts from this blog

Access GPIO from Linux user space

Launch an app from Android shell terminal

Android: adb push and read-only file system error