QT 水晶圆角按钮样式

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/ZuoYueXian/article/details/80500941

*QT 生成水晶圆角按钮样式*
不用任何图标就可以生成水晶按钮,看起来还是比较好看,直接上图看效果
这里写图片描述
可以通过QPushButton 和QToolButton 实现
QPushButton具体代码如下:

QPushButton{  
       min-width:80px;  
       min-height:32px;  
    }  
 QPushButton{  
    color:rgb(233, 236, 243);  
    min-height:20;  
    border-style:solid;  
    border-top-left-radius:2px;  
    border-top-right-radius:2px;  
    background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop:0 rgb(226,236,241),   
                                stop: 0.3 rgb(33,184,150),  
                                  stop: 1 rgb(29,170,140));  
    border:1px;  
    border-radius:5px;padding:2px 4px;/*border-radius控制圆角大小*/  
    }  
    QPushButton:hover{  /*鼠标放上后*/  
    color:rgb(233, 236, 243);  
    min-height:20;  
    border-style:solid;  
    border-top-left-radius:2px;  
    border-top-right-radius:2px;  
    background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop:0 rgb(226,236,241),   
                                stop: 0.3 rgb(37,189,252),  
                                  stop: 1 rgb(32,170,240));  
    border:1px;  
    border-radius:5px;padding:2px 4px;  
    }  
    QPushButton:pressed{ /*按下按钮后*/  
    color:rgb(233, 236, 243);  
    min-height:20;  
    border-style:solid;  
    border-top-left-radius:2px;  
    border-top-right-radius:2px;  
    background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop:0 rgb(226,236,241),   
                                stop: 0.3 rgb(38,190,255),  
                                  stop: 1 rgb(33,184,240));  
    border:1px;  
    border-radius:5px;padding:2px 4px;  
    };  

QToolButton 样式如下:

QToolButton{  
       min-width:80px;  
       min-height:32px;  
    }  
    QToolButton{  
    color:rgb(233, 236, 243);  
    min-height:20;  
    border-style:solid;  
    border-top-left-radius:2px;  
    border-top-right-radius:2px;  
    background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop:0 rgb(226,236,241),   
                                stop: 0.3 rgb(33,184,150),  
                                  stop: 1 rgb(29,170,140));  
    border:1px;  
    border-radius:5px;padding:2px 4px;/*border-radius控制圆角大小*/  
    }  
    QToolButton:hover{  /*鼠标放上后*/  
    color:rgb(233, 236, 243);  
    min-height:20;  
    border-style:solid;  
    border-top-left-radius:2px;  
    border-top-right-radius:2px;  
    background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop:0 rgb(226,236,241),   
                                stop: 0.3 rgb(37,189,252),  
                                  stop: 1 rgb(32,170,240));  
    border:1px;  
    border-radius:5px;padding:2px 4px;  
    }  
    QToolButton:pressed{ /*按下按钮后*/  
    color:rgb(233, 236, 243);  
    min-height:20;  
    border-style:solid;  
    border-top-left-radius:2px;  
    border-top-right-radius:2px;  
    background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop:0 rgb(226,236,241),   
                                stop: 0.3 rgb(38,190,255),  
                                  stop: 1 rgb(33,184,240));  
    border:1px;  
    border-radius:5px;padding:2px 4px;  
    }  
    QToolButton:checked{    /*选中后*/  
    color:rgb(233, 236, 243);  
    min-height:20;  
    border-style:solid;  
    border-top-left-radius:2px;  
    border-top-right-radius:2px;  
    background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop:0 rgb(226,236,241),   
                                stop: 0.3 rgb(38,190,255),  
                                  stop: 1 rgb(33,184,240));  
    border:1px;  
    border-radius:5px;padding:2px 4px;  
    }  
阅读更多
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页