# -*- coding: utf-8 -*-
import sys
from PyQt4.QtGui import *
from PyQt4.QtCore import *
class MainWindow(QWidget):
def __init__(self):
super(MainWindow, self).__init__()
self.setFixedWidth(200)
self.setFixedHeight(200)
stylesheet = \
".QWidget {\n" \
+ "border: 20px solid black;\n" \
+ "border-radius: 4px;\n" \
+ "background-color: rgb(255, 255, 255);\n" \
+ "}"
self.setStyleSheet(stylesheet)
if __name__ == '__main__':
app = QApplication(sys.argv)
main = MainWindow()
main.show()
sys.exit(app.exec_())
我想为带有样式表的自定义小部件添加边框,但样式表似乎不起作用,有什么问题吗?