【整理】PyQt加载QSS文件

原创文章,转载请注明: 转载自勤奋的小青蛙
本文链接地址: 【整理】PyQt加载QSS文件

参考:http://www.cnblogs.com/dcb3688/p/4540638.html

新建一份QSS文件css.qss:

QPushButton#pushButton{background-image: url(:/cssimg/img/btn_close_normal.png);width:39px;height:18px;padding-top:0px;border:0px;}
QPushButton#pushButton:hover{background-image:url(:/cssimg/img/btn_close_highlight.png);}
QPushButton#pushButton:pressed{background-image:url(:/cssimg/img/btn_close_down.png);}

QPushButton#pushButton_2{background-image: url(:/cssimg/img/icon_cog.png);width:16px;height:16px;padding-top:0px;border:0px;margin-right:15px;}
QPushButton#pushButton_2:hover{background-image:url(:/cssimg/img/icon_cogs.png);}

然后通过程序引入:

        file = QtCore.QFile('css.qss')
        file.open(QtCore.QFile.ReadOnly)
        styleSheet = file.readAll()
        styleSheet = unicode(styleSheet, encoding='utf8')
        QtGui.qApp.setStyleSheet(styleSheet)
原创文章,转载请注明: 转载自勤奋的小青蛙
本文链接地址: 【整理】PyQt加载QSS文件

文章的脚注信息由WordPress的wp-posturl插件自动生成



|2|left
打赏

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: