首页 > 解决方案 > QComboBox 样式表在 Ubuntu 16.04 LTS 上不起作用

问题描述

我使用 qss 文件将主题应用于我的应用程序。它是跨平台的。在 Windows 上,我可以按预期看到我想要的样式表。一旦我在 Ubuntu 16.04 LTS(带有肉桂桌面)上运行应用程序,我发现一切都很好,除了组合框。Combo Box 的弹出窗口看起来像原生 ubuntu 下拉菜单。它没有像我预期的那样显示。如何修复它

QComboBox
{
    background-color:rgba(0,0,0,0);
    border:1px solid rgba(255,255,255,30);
    border-radius:5px;
    padding-left:5px;
    padding-right:5px;
    min-height:40px;
}

QComboBox::drop-down
{
    subcontrol-origin: padding;
    subcontrol-position: top right;
    border:0px;
    background-color:rgba(0,0,0,0);
    width:25;
    border-top-right-radius:4px;
    border-bottom-right-radius:4px;
}

QComboBox QAbstractItemView
{
    background-color:#424B54;
    border:0px;
    border-radius:0px;
    outline: none;
    margin:0px;
    padding:5px;
}

QComboBox QAbstractItemView::item
{
    min-height:40px;
    color:rgba(255,255,255, 200);
    background-color: rgba(0, 0, 0, 100);
}

QComboBox QAbstractItemView::item:hover,QComboBox QAbstractItemView::item:selected,QComboBox QAbstractItemView::item:selected:hover
{
    min-height:40px;
    background-color: rgba(255,255,255, 120);
    color: rgba(0,0,0);
}

/*QComboBox:on
{
    background-color:rgba(146, 39, 142, 255);
}*/

QComboBox::down-arrow
{
    border-image: url(:/Theme/theme/dark/general/down.png);
    padding:5px;
}

QComboBox::down-arrow:on
{
    top: 1px;
    left: 1px;
}

注意 我观察到 QScrollBar 也采用原生样式表

标签: qtcomboboxqt5stylesheet

解决方案


推荐阅读