title: How to set global style sheets to custom widgets?
body: <p>In the main window I can set CSS styles for different standard widgets: </p>
  
  <blockquote>
    <p>setStyleSheet("QComboBox { background-color: red; } QLabel { background-color: blue; }")</p>
  </blockquote>
  
  <p>These styles will be applied in child widgets with those names.</p>
  
  <p>But is it possible to set styles for widgets defined by me in the same fashion?</p>
  
  <p>Then this widget should obtain its style by its class name. I can't seem to find corresponding function that would obtain the style sheet by class name.</p>
  
  <p>Here is an example.</p>
  
  <p>---custom-widget.h---</p>
  
  <pre><code>#include &lt;QWidget&gt;
  
  class MyCustomWidget : public QWidget {
    Q_OBJECT
  public:
    MyCustomWidget(QWidget *parent) : QWidget(parent) { }
  };
  </code></pre>
  
  <p>---main.cpp---</p>
  
  <pre><code>#include &lt;QApplication&gt;
  #include &lt;QWidget&gt;
  #include &lt;QLayout&gt;
  #include &lt;QLabel&gt;
  #include "custom-widget.h"
  
  int main(int argc, char **argv) {
    QApplication   app (argc, argv);
    QWidget        mainWindow;
    QVBoxLayout    mainLayout(&amp;mainWindow);
    QLabel         label("I am a label", &amp;mainWindow);
    MyCustomWidget customWidget(&amp;mainWindow);
  
    mainLayout.addWidget(&amp;label);
    mainLayout.addWidget(&amp;customWidget);
    customWidget.setMinimumSize(100, 300);
  
    mainWindow.setStyleSheet(
      "QLabel { background-color: #5ea6e3; }"
      "MyCustomWidget { background-color: #f00000; }"
    );
  
    mainWindow.show();
  
    return app.exec();
  }
  </code></pre>
  
  <p>---main.pro---</p>
  
  <pre><code>CONFIG += qt
  QT += core gui widgets
  TEMPLATE = app
  TARGET = main
  
  HEADERS = main.h custom-widget.h
  SOURCES = main.cpp
  </code></pre>