How I can use external stylesheet for PyQT4 project?
<p>I am just creating a remote app with pyqt4. So, there is lots of css on the UI. I was wondering how to use external stylessheets like in web apps.</p>

<p>For Example: </p>

<pre><code>button_one.setStyleSheet("QPushButton { background-color:#444444; color:#ffffff; border: 2px solid #3d3d3d; width: 15px; height: 25px; border-radius: 15px;}"
                                 "QPushButton:pressed { background-color:#ccc;}")
Instead of the above code 
button_one.setStyleSheet("QPushButton.styleclass or #styleid")
</code></pre>

<p>There's no need to set a stylesheet on each widget. Just set one stylesheet for the whole application:</p>

<pre><code>stylesheet = """
QPushButton#styleid {
    background-color: yellow;
}
QPushButton.styleclass {
    background-color: magenta;
}
QPushButton {
    color: blue;
}
"""

QtGui.qApp.setStyleSheet(stylesheet)    
</code></pre>

<p>The qss id of a widget can be specified with <code>setObjectName</code>:</p>

<pre><code>button_one.setObjectName('styleid')
</code></pre>

<p>The qss class can be specified with <code>setProperty</code>:</p>

<pre><code>button_two.setProperty('class', 'styleclass')
</code></pre>

<p>For other qss selectors, see <a href="https://doc.qt.io/qt-4.8/stylesheet-syntax.html#selector-types" rel="nofollow">Selector Types</a> in the Qt docs.</p>

python qt user-interface pyqt4