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:
MyWidget->setAutoFillBackground(true); // We set a white background color for this example QPalette FramePalette(MyWidget->palette()); FramePalette.setColor(QPalette::Background, Qt::white); MyWidget->setPalette(FramePalette);
Please note that for have our custom backgound color showed is need to set the setAutoFillBackground flag to true as the example.
Comments
Post a Comment