title: Load an external stylesheet in Qt
body: <p>I'm new to Qt, I read all the documentation about Stylesheets and I almost know how to style my app. My files are like this :</p>
  
  <p><code>Project/ -&gt; 
  babel.pro resources.qrc
  gui/ -&gt; QtFiles, stylesheet.qss
  app/ -&gt; main.cpp</code></p>
  
  <p>My main looks like this : </p>
  
  <pre><code>int main(int ac, char **av) {
    MyApplication app(ac, av);
    MyWidget widget;
  
    QFile File(":/gui/stylesheet.qss");                                                  
    File.open(QFile::ReadOnly);
    QString StyleSheet = QLatin1String(File.readAll());
  
    app.setStyleSheet(StyleSheet);
    widget.show();
  
    return app.exec();
  
  }
  </code></pre>
  
  <p>MyApplication.hpp : </p>
  
  <pre><code>class MyApplication : public QApplication {
  
  public:
  
    MyApplication(int argc, char **av) : QApplication(argc, av) {}
    virtual ~MyApplication() {}
    virtual bool notify(QObject *rec, QEvent *ev) {
      try {
        return QApplication::notify(rec, ev);
      }
      catch (const std::exception &amp;e) {
        std::cerr &lt;&lt; e.what() &lt;&lt; std::endl;
        exit(0);
      }
      return false;
    }
  };
  </code></pre>
  
  <p>And finally MyWidget.cpp :</p>
  
  <pre><code>MyWidget::MyWidget(QWidget *parent) : QWidget(parent)
  {
    QVBoxLayout *mainLayout = new QVBoxLayout;
  
    setFixedSize(1920, 1200);
    setWindowTitle(tr("Babel"));
  
    _tabWidget = new QTabWidget;
    _tabWidget-&gt;addTab(new Home(), tr("Home"));
    _tabWidget-&gt;addTab(new Contact(), tr("Contact"));
  
    _tabWidget-&gt;resize(10, _tabWidget-&gt;height());
  
    mainLayout-&gt;addWidget(_tabWidget);
    setLayout(mainLayout);
  }
  </code></pre>
  
  <p>I added this line in my babel.pro (which is the general .pro for the compilation) : <code>RESOURCES += resources.qrc</code></p>
  
  <p>But I have this error when running the app : <code>QIODevice::read: device not open</code></p>
  
  <p><strong>EDIT :</strong></p>
  
  <p>My resources file looks like this : </p>
  
  <pre><code>&lt;!DOCTYPE RCC&gt;                                                                        
  &lt;RCC version="1.0"&gt;
       &lt;qresource&gt;
          &lt;file&gt;/gui/stylesheet.qss&lt;/file&gt;
       &lt;/qresource&gt;
  &lt;/RCC&gt;
  </code></pre>