Programming/qt

QT QLabel 배경색상 넣기

구차니 2026. 4. 29. 15:26

음.. stylesheet를 건드리지 않으면 방법이 없나?

일단은... autoFillBackgroun를 체크하지 않아도 되긴 한다.

 

 

title->setAutoFillBackground(true); // IMPORTANT!
QPalette pal = title->palette();
pal.setColor(QPalette::Window, QColor(Qt::black));
title->setPalette(pal);

title->setStyleSheet("background-color: red;")
title->setStyleSheet("background-color: cornsilk;")

[링크 : https://forum.qt.io/topic/4197/qlabel-background-color/10]