1. 程式人生 > >QT 水晶圓角按鈕樣式

QT 水晶圓角按鈕樣式

*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;  
    }