Qt QSS教程 QComboBox
1 QComboBox { 2 /* 边框宽度,线条样式,颜色 */ 3 border:3px solid red; 4 5 /* 倒角 */ 6 border-radius:8px; 7 8 /* 内边框 */ 9 padding:1px 18px 1px 3px;10 11 min-width:100px;12 }13 14 QComboBox:editable {15 background:green;16 }17 18 /* 渐变色:从左到右,黑白渐变 */19 QComboBox:!editable,QComboBox::drop-down:editable {20 background:qlineargradient(x1:0, y1:0, x2:1, y2:0,21 stop:0 rgb(0,0,0), stop:1 rgb(255,255,255));22 }23 24 /* 当下拉框打开时,背景颜色渐变 */25 QComboBox:!editable:on, QComboBox::drop-down:editable:on {26 background: qlineargradient(x1: 0, y1: 0, x2: 1, y2: 0,27 stop: 0 #D3D3D3, stop: 0.4 #D8D8D8,28 stop: 0.5 #DDDDDD, stop: 1.0 #BBBBBB);29 }30 31 /* 当下拉框打开时, 移动显示框文本位置*/32 QComboBox:on {33 padding-top: 3px;34 padding-left: 4px;35 }36 37 /* 下拉按钮 */38 QComboBox::drop-down {39 subcontrol-origin: padding;40 41 /* 按钮位置,右上角 */42 subcontrol-position: top right;43 44 /* 按钮宽度 */45 width: 25px;46 47 /* 一条边框线控制 */48 border-left-width: 3px;49 border-left-color: red;50 border-left-style: solid;51 52 /* 倒角 */53 border-top-right-radius: 3px;54 border-bottom-right-radius: 3px;55 }56 57 /* 下拉按钮图片 */58 QComboBox::down-arrow {59 border-image: url(:/images/02.bmp);60 }61 62 /* 下拉按钮位移 */63 QComboBox::down-arrow:on {64 top: 1px;65 left: 1px;66 }67 68 /* 下拉列表里的颜色 */69 QComboBox QAbstractItemView {70 border: 2px solid darkgray;71 selection-background-color: green;72 }