View Full Version : setAutoFilledBackground leads to different result.

14th May 2014, 12:23
Hello all,

while calling setAutoFillBackground() in QLabel and QCheckBox lead to different results in my project.

here the code of my custom widgets - statictext(QLabel) and checkbox(QCheckbox)

void StaticText :: setTransparent(bool bTransparent)
setAutoFillBackground(! bTransparent);

void CheckBox :: setTransparent(bool bTransparent)
setAutoFillBackground(! bTransparent);

the attached picture shows the issue:


why by calling both setAutoFillBackground(true) makes the custom widgets behave differently, in which statictext displays the parents background color and checkbox with a system default light gray?

PS: please just consider i dont use stylesheet in my project. And im sure i didnt set up their background color somewhere in the project. And they have a same parent widget.

I am using Qt 4.8.6 under Windows 7



well, the problem is the default backgroundRole() of QLabel and QCheckBox is different, so they took the colors of each color role. Question closed...