1. 程式人生 > >Qt之QSlider樣式表設定

Qt之QSlider樣式表設定

最近,做了一些的的Qt的關於QSlider的樣式表。

簡單的舉下例子:

樣式表中的內容:

QSlider::groove:horizontal {

border: 0px solid #bbb;

}

QSlider::sub-page:horizontal {

background: rgb(235,97,0);

border-radius: 0px;

margin-top:8px;

margin-bottom:8px;

}

QSlider::add-page:horizontal {

background: rgb(255,255, 255);

border: 0px solid #777;

border-radius: 2px;

margin-top:8px;

margin-bottom:8px;

}

QSlider::handle:horizontal {

background: rgb(255,153,102);

border: 1px solid rgb(255,153,102);

width: 14px;

height:10px;

border-radius: 7px;

margin-top:2px;

margin-bottom:2px;

}

QSlider::handle:horizontal:hover {

background: rgb(255,128,6);

border: 1px solid rgba(102,102,102,102);

border-radius: 7px;

}

QSlider::sub-page:horizontal:disabled {

background: #bbb;

border-color: #999;

}

QSlider::add-page:horizontal:disabled {

background: #eee;

border-color: #999;

}

QSlider::handle:horizontal:disabled {

background: #eee;

border: 1px solid #aaa;

border-radius: 4px;

}





ui.horizontalSlider_sound->setStyleSheet(“QSlider {max-width:122; 最小寬度:122; border-image:url();} \ 
		                           QSlider :: groove:horizo​​ ntal {background-image:url(:/ res / Resources / bk / soundsliderbk.png); 身高:18px;} \ 
		                           QSlider ::子頁面:horizo​​ ntal {background-image:url(:/ res / Resources / bk / soundsliderpos.png); 
邊框:5px固體透明; border-radius:5px;} \
QSlider :: add-page:horizo​​ ntal {background-color:transparent;} \ QSlider :: handle:horizo​​ ntal {background-image:url(:/ res / Resources / bk / soundsliderselect.png);寬度:32px;高度:32px; 保證金左:-5px; 邊距:-8px; 與容限右:-5px;
邊距:-7px;}“);

或者修改下最上面的那個樣式表: