美文网首页
QSS设置QPushButton图标和文字同时显示

QSS设置QPushButton图标和文字同时显示

作者: BrokenRainK | 来源:发表于2022-03-14 14:18 被阅读0次

    图标左文字右

    方法一

    QPushButton {
        padding: 8px;    //根据自己需求修改
        text-align: right;
        background-position: left;
        background-image: url(:/icon.png);
        background-repeat: repeat-no-repeat;
        background-origin:content;
    }
    

    方法二

    QPushButton {
        text-align: left;
        qproperty-icon: url(:/icon.png);
        qproperty-iconSize: 24px 24px;
    }
    

    图标右文字左

    QPushButton {
        padding: 8px;
        text-align: left;
        background-position: right;
        background-image: url(:/icon.png);
        background-repeat: repeat-no-repeat;
        background-origin:content;
    }
    

    图标上文字下

    QPushButton {
        padding: 5px;
        min-height: 40px;
        text-align: bottom;
        background-position: top;
        background-image: url(:/icon.png);
        background-repeat: repeat-no-repeat;
        background-origin:content;
    }
    

    图标下文字上

    QPushButton {
        padding: 5px;
        min-height: 40px;
        text-align: top;
        background-position: bottom;
        background-image: url(:/icon.png);
        background-repeat: repeat-no-repeat;
        background-origin:content;
    }
    

    相关文章

      网友评论

          本文标题:QSS设置QPushButton图标和文字同时显示

          本文链接:https://www.haomeiwen.com/subject/gcojdrtx.html