在Mac OSX中设置QComboBox样式

问题描述 投票:4回答:3

我在Mac OSX中为Qt5的组合框弹出框架设计了一些问题

我的QComboBox样式表

QComboBox {
    font-size: 11px;
    height: 16px;
    padding: 1px 5px 1px 5px;
    border: 2px groove #4B4F4F;
    border-bottom: 2px ridge #424545;
    border-right: 2px ridge #424545;
    border-radius: 3px;
    color: #DEDEDE;
    background: qlineargradient(x1:0, x2:0, y1:0, y2:1, stop:0 #6B6E6E, stop:1 #595B5B);
}
QComboBox::drop-down {
    subcontrol-origin: padding;
    subcontrol-position: top right;
    width: 14px;
    border-left-width: 1px;
    border-left-color: #999999;
    border-left-style: solid; /* just a single line */
    border-top-right-radius: 3px; /* same radius as the QComboBox */
    border-bottom-right-radius: 3px;
}
QComboBox::down-arrow {
    height: 8px;
    width: 8px;
    image: url(:/resources/images/downarrow.png);
}
QComboBox:on {
    border: 1px solid #00A7CC;
    padding-left: 6px;
}
QComboBox QAbstractItemView {
    min-width: 100px;
    outline: 1px solid #808A8A;
    border: 1px solid #373838;
    selection-background-color: #808A8A;
    background-color: #4A4C4F;
}
QComboBox:!enabled {
    color: #909090;
}

Mac OSX上的结果如下所示:

以下我想改变的事情:

  • 摆脱弹出窗口顶部和底部的空白区域
  • 隐藏左侧的勾号或更改其大小

编辑:

我可以解决白色空间的问题,但不能解决问题。它看起来仍然很难看。

我将QComboBox的填充更改为:

QComboBox {
        padding: 0px 5px 0px 5px;
....

我的左上角还有一个小点,不知道我怎么能隐藏它

c++ macos qt qtstylesheets
3个回答
0
投票

我有同样的问题,但仍然没有找到解决方案,所以我改变了样式工厂:

#if defined(Q_OS_MAC)
    ui->cb_action->setStyle(QStyleFactory::create("Windows"));
#endif

0
投票

我也想隐藏刻度线,但QStyleFactory的解决方案效果不佳。所以我一直在努力,我找到了另一个解决方案,为我做了这个诀窍:

ui->comboBox->setItemDelegate(new QStyledItemDelegate());

0
投票

它适用于:

ui->cb_action->setStyle(QStyleFactory::create("Windows"));

......正如vic-lin所建议的那样。

© www.soinside.com 2019 - 2024. All rights reserved.