1

I tried many different options to style a QCombobox but I still have some issues on mac osx. It looks like this : look on osx http://img90.imageshack.us/img90/9550/stylesheets.png

I'd like to remove the white top/bottom of the view list but I can't seem to find a way to do this.

Here's the code I have now :

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);
}

Any help is appreciated

Thanks

Lex
  • 413
  • 1
  • 7
  • 19
  • possible duplicate of [Style QComboBox popup menu margin Qt 4](http://stackoverflow.com/questions/9064993/style-qcombobox-popup-menu-margin-qt-4) – Lol4t0 Apr 28 '13 at 10:38
  • The answer on this post doesn't solve my issue. – Lex Apr 28 '13 at 12:29
  • I partially resolved the issue by changing the QStyle of the QCombobox . It is set to QWindowsStyle...so I don't have the issue on mac osx. Still the problem isn't solved in itself – Lex Apr 28 '13 at 12:44

1 Answers1

3

Use own application style (based on QProxyStyle) & override QProxyStyle::styleHint as:


    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 );   
    }

install own style to qApp instance:


    qApp->setStyle( new CMyProxyStyle );

  • Glad to see you solved the problem;) I confirm this is working. With this method can you also conserve changes made to the QComboBox through style-sheets ? If so how ? – Lex Jan 10 '14 at 12:01
  • yes, because we use in our app custom QSS (also & for comboboxes) – Artiom Khachaturian Jan 11 '14 at 06:25