title: How to get stylesheet change event in a QWidget?
body: <p>I'm trying to read a global stylesheet for all widgets and apply it to the QApplication instance.</p>
  
  <p>This styles all widgets correctly, except that I can not query style options, like font and font sizes, in the main window constructor and its children widget's constructors, because at that moment the stylesheet is not applied to it yet.</p>
  
  <p><strong>So I need to :</strong></p>
  
  <ul>
  <li>either make global stylesheet available in the mainwindow constructor; </li>
  <li>catch the event in the widget when style sheet is applied.</li>
  </ul>
  
  <p>Is there a way to achieve one of those?</p>
  
  <p>My code for the main window is below :</p>
  
  <pre><code>int main(int argc, char **argv)
  {   
      QWSServer::QWSServer::setBackground(QBrush(QColor(0, 0, 0, 255)));
      QApplication app(argc, argv);
  
      QFile stylesheet("/usr/bin/app.qss");
      stylesheet.open(QFile::ReadOnly|QFile::Text);
      QTextStream styleSheetStyle(&amp;stylesheet);
  
      app.setStyleSheet(styleSheetStyle.readAll());
  
      MainWindow * pWindow = new MainWindow();
      pWindow-&gt;setWindowFlags(Qt::FramelessWindowHint);
      pWindow-&gt;show();
  
      return app.exec();  
  }
  </code></pre>
  
  <p>In the widget, where style is needed:</p>
  
  <pre><code>void paintText(QPixmap *target, const QString &amp;text)
  {
      QPainter painter(target);
      painter.setPen(QColor(184,188,193,255));
      painter.setFont(property("font").value&lt;QFont&gt;());
      style()-&gt;drawItemText(&amp;painter, 
                           target-&gt;rect().adjusted(0,0,0,-15), 
                           Qt::AlignHCenter|Qt::AlignBottom, 
                           QPalette(QColor(184,188,193,255)), 
                           true, 
                           text);
      painter.end();
  }
  </code></pre>
  
  <p>If that paint function is called in the widget's constructor, then font is default, if called in the show event, then font is the one specified by the global style sheet.</p>
  
  <p>But that function only needs to be called once, so I don't want to paint it in the show event, even though I can use a flag to make it run only on the first show event.</p>