c++ - macOS 上的 Qt 组合框样式表

标签 c++ qt qtstylesheets

我尝试了许多不同的选项来设置 QCombobox 的样式,但我在 mac osx 上仍然遇到一些问题。 看起来像这样:look on osx http://img90.imageshack.us/img90/9550/stylesheets.png

我想删除 View 列表的白色顶部/底部,但我似乎找不到执行此操作的方法。

这是我现在的代码:

QComboBox{
    color:rgba(200,200,200,255);
    background-color:rgba(71,71,71,255);
    selection-color:rgba(243,149,0,255);
    selection-background-color:rgba(71,71,71,255);
}
QComboBox QAbstractItemView{
    border-radius:0px;
    border:0px;
    selection-background-color:rgba(71,71,71,255);
    background:rgba(71,71,71,255);
    color:rgb(200,200,200);
}

感谢任何帮助

谢谢

最佳答案

使用自己的应用程序样式(基于 QProxyStyle)并重写 QProxyStyle::styleHint 为:


    int CMyProxyStyle::styleHint( StyleHint hint, const QStyleOption*
    option = 0, const QWidget* widget = 0, QStyleHintReturn* returnData =
    0 ) const   
    {
        if( SH_ComboBox_Popup == hint )
          return 0;//disable combo-box popup top & bottom areas
        return QProxyStyle::styleHint( hint, option, widget, returnData );   
    }

将自己的样式安装到 qApp 实例:


    qApp->setStyle( new CMyProxyStyle );

关于c++ - macOS 上的 Qt 组合框样式表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16261568/

相关文章:

c++ - Qt/C++中如何从QApplication继承样式表

c++ - 在 C++ 中使用 std::addressof() 函数模板而不是使用 operator& 有什么好处吗?

Qt:样式化 QTabWidget

c++ - vector 、矩阵、代数类设计

c++ - Qt:我应该什么时候使用 Q_DECLARE_METATYPE?

c++ - 对 CoInitialize@4 和 CoUninitialize@0 的 undefined reference

c++ - 无法使用 clang_complete 完成 qt

c++ - QTabBar 选项卡大小不随样式表字体缩放

C++ 函数判断 unicode 点是否为 'letter' 而不是标点符号的数量

c++ - 在 Windows 上为 Linux 交叉编译(链接器输出文件不会在 Linux 上作为可执行文件运行并且具有 undefined symbol )