Qt_GUI_BG_7_2 - 8BitsCoding/RobotMentor GitHub Wiki
๋ชฉ์ฐจ
QPalette
Working with Palettes:
- Retrieve(๊ฒ์) the Palette for the current widget with the
Qwidget::palette()
method - Modify the parts you want customized
- Reset the palette to the widget using the
QWidget::setPalette()
method
์์ ์์ : label์ palette ์ ์ฉํ๊ธฐ
์์ ๊ฐ์ ๋ค์ด์ผ๋ก๊ทธ๋ฅผ ํ๋ ๋ง๋ค์ด ๋ณธ๋ค.
๊ทธ๋ฆฌ๊ณ Palette๋ฅผ ์์ ํด๋ณด์.
#include "QtGuiApplication1.h"
QtGuiApplication1::QtGuiApplication1(QWidget *parent)
: QWidget(parent)
{
ui.setupUi(this);
// Retrieve the palette for the label
QPalette palette = ui.label->palette();
ui.label->setAutoFillBackground(true);
// Modify the palette with our changes
palette.setColor(QPalette::Window, Qt::blue);
palette.setColor(QPalette::WindowText, Qt::red);
// Reset the palette to the widget
ui.label->setPalette(palette);
}