Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Do not dynamically set complete stylesheets. Instead, define an application wide stylesheet using dynamic stylesheet that you parse once at application startup. Then, in the stylesheet, define dynamic stylesheet properties as detailed in the <a href="http://qt.nokia.com/doc/4.6/stylesheet-examples.html#customizing-using-dynamic-properties" rel="noreferrer">documentation</a>:</p> <blockquote> <p>There are many situations where we need to present a form that has mandatory fields. To indicate to the user that the field is mandatory, one effective (albeit esthetically dubious) solution is to use yellow as the background color for those fields. It turns out this is very easy to implement using Qt Style Sheets. First, we would use the following application-wide style sheet:</p> <pre><code>*[mandatoryField="true"] { background-color: yellow } </code></pre> </blockquote> <p>In your case, you could probably do something like this:</p> <pre><code>QPushButton[state="on"] { background-color: green; } QPushButton[state="off"] { background-color: red; } </code></pre> <p>Then update the button 'state' property:</p> <pre><code>pushButton-&gt;setProperty("state", "on"); pushButton-&gt;setStyle(QApplication::style()); </code></pre> <p>Unfortunately, for Qt 4.6 you will need to force a recomputation of the stylesheet by resetting the style of the widget, hence the <code>setStyle()</code> call.</p> <p>Using dynamic stylesheets in this way is very fast. I am working on an application that makes heavy use of dynamic stylesheet properties and have not noticed any performance degredation.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload