以下是一个精美的 QSS 样式,可以应用于 Qt 的 ComboBox 控件:

QComboBox {
    border: 1px solid #bfbfbf;
    border-radius: 3px;
    padding: 1px 18px 1px 3px;
    min-width: 6em;
    font-size: 14px;
    color: #666666;
    selection-background-color: #e6e6e6;
    selection-color: #666666;
    background-image: url(':/images/arrow_down.png');
    background-repeat: no-repeat;
    background-position: right center;
    padding-right: 20px;
}

QComboBox:hover {
    border-color: #7bc4ff;
}

QComboBox::drop-down {
    subcontrol-origin: padding;
    subcontrol-position: top right;
    width: 20px;
    border-left-width: 1px;
    border-left-color: #bfbfbf;
    border-left-style: solid;
    background-color: #f8f8f8;
}

QComboBox::down-arrow {
    image: url(':/images/arrow_down_blue.png');
    width: 10px;
    height: 10px;
    margin-top: 5px;
    margin-right: 5px;
}

QComboBox::down-arrow:hover {
    image: url(':/images/arrow_down_white.png');
}

QComboBox::drop-down:hover {
    background-color: #e6e6e6;
}

QComboBox::drop-down:on {
    background-color: #f0f0f0;
}

QComboBox::item {
    padding: 5px;
    background-color: transparent;
}

QComboBox::item:selected {
    background-color: #e6e6e6;
}

QComboBox::item:hover {
    background-color: #f0f0f0;
}

您可以通过将 QComboBox 的样式表设置为上面的 QSS 样式来应用它。如果您需要使用不同的图像,请在相应的位置更改 URL。

Qt ComboBox 精美 QSS 样式示例

原文地址: https://www.cveoy.top/t/topic/m2zQ 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录