I have about 40 buttons that are also indicators (On or Off) and once a second I refresh the color of these indicators depending on the state. I do this by changing the sty
Yes. I found that with Qt 4.6.2 on Linux, setting a stylesheet to change the colour of the text on a QLabel is very slow.
The dynamic stylesheet looked like a great solution but for me, the necessary setStyle()
was just as expensive as setStyleSheet()
!
After much experimentation, I found this alternative to be at least twice as quick, and usually more than 50 times as quick:
QPalette palette = lbl->palette();
palette.setColor(QPalette::WindowText, Qt::gray);
lbl->setPalette(palette);
Depending on how your (static) stylesheet is set up, you'd have to replace QPalette::WindowText
with QPalette::Window
or QPalette::Button
. See the QPalette documentation for details.