In GroupBox I've placed few QLabels. Now - depending on which of this labels I click - I want to change background colour of one of those QLabel.
I've tried
if (somethink)
palette.
setColor(label
->backgroundRole
(),
QColor(Qt
::blue));
else
palette.
setColor(label
->backgroundRole
(),
QPalette::Window);
label->setText(someText);
label->setPalette(palette);
label->setAutoFillBackground(true);
label->update();
QPalette palette = label->palette();
if (somethink)
palette.setColor(label->backgroundRole(),QColor(Qt::blue));
else
palette.setColor(label->backgroundRole(),QPalette::Window);
label->setText(someText);
label->setPalette(palette);
label->setAutoFillBackground(true);
label->update();
To copy to clipboard, switch view to plain text mode
In the result - if i click on QLabel which should change background of others - no effect. When label->setAutoFillBackground(true); is set - widget turns him self into black block. When i click on widgets which should change background - then they are changing it to a proper one.
Then I've tried Style sheets. In places where I was changing palette - now I've placed
label->setStyleSheet("QLabel { background-color: blue }");
label->setStyleSheet("QLabel { background-color: blue }");
To copy to clipboard, switch view to plain text mode
and where I reset
label->setStyleSheet("");
label->setStyleSheet("");
To copy to clipboard, switch view to plain text mode
No difference.
PS. I'm coding under Windows XP. My application is using different styles like QPlastique, QWindows, QMotif - under each of them I see no effect from above code.
Bookmarks