提供一个复杂好看的QComboBox样式表
时间: 2023-09-10 22:15:27 浏览: 100
以下是一个比较复杂的QComboBox样式表,可以用来美化QComboBox外观:
```
QComboBox {
border: 1px solid #C4C4C4;
border-radius: 4px;
padding: 2px 20px 2px 5px;
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 #F6F6F6, stop: 0.4 #E0E0E0,
stop: 0.5 #D8D8D8, stop: 1.0 #C3C3C3);
min-width: 100px;
}
QComboBox:hover, QComboBox:focus {
border: 1px solid #7D7D7D;
}
QComboBox::drop-down {
background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
stop: 0 #F6F6F6, stop: 0.4 #E0E0E0,
stop: 0.5 #D8D8D8, stop: 1.0 #C3C3C3);
border-radius: 4px;
}
QComboBox::down-arrow {
image: url(arrow-down.png);
width: 12px;
height: 12px;
}
QComboBox::down-arrow:hover {
image: url(arrow-down-hover.png);
}
QComboBox QAbstractItemView {
border: 1px solid darkgray;
selection-background-color: lightgray;
background-color: white;
outline: none;
}
QComboBox::item {
padding: 2px 5px;
}
QComboBox::item:selected {
background-color: lightgray;
}
```
这个样式表设置了QComboBox的边框、圆角、内边距、背景颜色和最小宽度。它还定义了下拉按钮的样式和箭头图像,并设置了下拉列表的样式。请注意,您需要将arrow-down.png和arrow-down-hover.png替换为实际的箭头图像。此外,还可以通过样式表设置QComboBox的字体、字号和字体颜色等属性。
阅读全文