11.8 QSS语法声明 - 背景设置

一、QSS语法声明 - 背景设置

1.基本概念

 '''样式叠加
        hb = QHBoxLayout(self)
        for i in range(0, 4):
            btn = QPushButton(self)
            btn.move(300, 300)
            # btn.resize(110, 110)
            btn.setFixedSize(110, 110)
            print(i)
            btn.setStyleSheet("""
            QPushButton{
                padding-left: -%dpx;
                padding-top: -%dpx;
                }
            """ % (i * 175 + 25, 35))
            hb.addWidget(btn)
        '''

        '''
        background
        background-color  # 背景颜色
        background-image  # 背景图片
        background-position  # 背景位置
        background-origin  # 背景延伸范围
        background-clip  # 裁剪掉边框外的部分
        background-repeat  # 背景重复
        background-attachment  # 固定背景图像,取值scroll(背景跟随滚动)和fixed(背景不滚动)
        '''

        '''背景图片调整
        QPushButton{
            background-image: url(btn-ico.jpg);
            border: 5px solid lightblue;
            background-origin: content;
            background-clip: padding;
            padding-left: -25px;  // 边框宽度也要计算在内
            padding-top: -35px;
        }
        '''

posted @ 2022-03-24 22:04  Trouvaille_fighting  阅读(313)  评论(0)    收藏  举报