Does the style use StyleSheets dynamically, adds a lot of calculation

I have about 40 buttons, which are also indicators (On or Off), and once a second I update the color of these indicators depending on the state. I do this by modifying the stylesheet. Does this end with this kill, and if so, should I only set a new stylesheet when the indicator has changed, or should I use something like QBrush?

+5
source share
3 answers

Yes. I found that with Qt 4.6.2 on Linux, setting up a stylesheet to change the color of text in QLabel is very slow.

, setStyle() , setStyleSheet()!

, 50 :

QPalette palette = lbl->palette();
palette.setColor(QPalette::WindowText, Qt::gray);
lbl->setPalette(palette);

, () , QPalette::WindowText QPalette::Window QPalette::Button. . QPalette.

+1

. , . , :

, . , , ( ) . , Qt. -, :

*[mandatoryField="true"] { background-color: yellow }

- :

QPushButton[state="on"] {
  background-color: green;
}

QPushButton[state="off"] {
  background-color: red;
}

"" :

pushButton->setProperty("state", "on");
pushButton->setStyle(QApplication::style());

, Qt 4.6 , , , setStyle().

. , - .

+10

, , .

+1

All Articles