I don't seem to get the Stylesheets to work in PySide. Is there some special syntax that differs from PyQt?
Here's a small example code:
import sys
from PySide import QtGui
class Example(QtGui.QWidget):
def __init__(self):
super(Example, self).__init__()
self.initUI()
def initUI(self):
okButton = QtGui.QPushButton("OK")
cancelButton = QtGui.QPushButton("Cancel")
testWidget = QtGui.QWidget()
hbox2 = QtGui.QHBoxLayout()
hbox2.addWidget(okButton)
testWidget.setLayout(hbox2)
testWidget.setObjectName("testWidget")
testWidget.setStyleSheet("QWidget#testWidget { \n border: 2px solid gray; \n border-radius: 3px; \n }")
hbox = QtGui.QHBoxLayout()
hbox.addWidget(testWidget)
hbox.addWidget(cancelButton)
self.setLayout(hbox)
self.setGeometry(300, 300, 300, 150)
self.setWindowTitle('Expample')
self.show()
app = QtGui.QApplication(sys.argv)
ex = Example()
sys.exit(app.exec_())
The result is:
If I change from PySide import QtGui
to from PyQt4 import QtGui
, I receive the following result:
Why doesn't the Stylesheet work in PySide?