PyQt5基础学习-子控件QSS的设置

设置控件的名字,对控件下面的子控件进行设置QSS

QSSSubControl.py 

"""
QSS子控件选择器
QComboBox
"""
from PyQt5.QtWidgets import *
import sys

class QSSSubControl(QWidget):
    def __init__(self):
        super(QSSSubControl, self).__init__()
        self.setWindowTitle("QSS子控件选择器")
        combo = QComboBox(self)
        combo.setObjectName("myComboBox")
        combo.addItem("Window")
        combo.addItem("Linux")
        combo.addItem("Mac OS X")

        combo.move(50, 50)

        self.setGeometry(250, 200, 320, 150)


if __name__ == "__main__":
    app = QApplication(sys.argv)
    form = QSSSubControl()
    # drop-down: 下拉框的图片设置
    qssStyle = """
      QComboBox#myComboBox::drop-down {
            image:url(../picture/F6fhJr.jpg)
        }
    """
    form.setStyleSheet(qssStyle)
    form.show()
    sys.exit(app.exec_())

 

 

posted @ 2022-02-13 11:25  c语言我的最爱  阅读(658)  评论(0编辑  收藏  举报