한국어
Qt
 

가장 권장되는 방법은 Qt 스타일 시트를 사용하는 것이다.

 
QLabel의 텍스트 색과 배경색을 변경하려면 다음과 같이한다. :
QLabel* pLabel = new QLabel;
pLabel->setStyleSheet("QLabel { background-color : red; color : blue; }");
 
Qt 스타일 시트를 사용하지 않고 QLabel의 QPalette 을 이용할 수도 있지만 플랫폼 및 스타일에 따라 결과가 다를 수 있다.
 
Qt 문서에 따르면 :
QPalette를 사용한다고해서 모든 스타일에서 작동하는 것은 아니다. 플랫폼의 지침과 기본 테마 엔진에 의해 제한되기 때문이다.
 
QPalette를 사용하려면 이런 식으로 할 수 있다 :
QPalette palette = ui->pLabel->palette();
palette.setColor(ui->pLabel->backgroundRole(), Qt::yellow);
palette.setColor(ui->pLabel->foregroundRole(), Qt::yellow);
ui->pLabel->setPalette(palette);
 
그러나 QPalette를 사용하는 것보다 Qt 스타일 시트를 사용하는 것이 좋다.