1

I've tried to make QMenu and QComboBox item's corners rounded. And i have a result. But i can't force only first and last items become rounded. So, it should look like this:

.

But with this code below i can only round all items. I've tried to call QListView::item:first and QListView::item:last, but it didn't help.

css
/* ======= QMenu ======= */
QMenu {
    background-color: #FFFFFF;
    border: 2px solid #CCCCCC;
    border-radius: 7px;
    padding: 0px;
}
QMenu::item {
    padding: 5px;
    border-radius: 4px;
}
QMenu::item:selected {
    background-color: #D3E3ED;
    color: #3B3B3B;
}



/* ======= QComboBox ======= */

QComboBox {
    combobox-popup: 0;
    border: 2px solid #CCCCCC;
    border-radius: 7px;
    min-width: 6em;
    padding: 7px;
}
QComboBox:on{
    border-bottom-left-radius: 0px; 
    border-bottom-right-radius: 0px;    
    background-color: #D3E3ED;

}
QComboBox::drop-down{
    border: 0px;
}
QComboBox::down-arrow {
    image: url(:/icons/arrow_down.svg);
    width: 10px;
    height: 10px;
    margin-right: 10px;
}
QComboBox::down-arrow:on {
    image: url(:/icons/arrow_up.svg);
}
QComboBox QListView{
    top: 2px;   
    border: 2px solid #CCCCCC;
    border-bottom-left-radius: 7px; 
    border-bottom-right-radius: 7px;    
    background: #FFFFFF;
    padding:0px;
}
QListView::item:hover{
    background: #D3E3ED;
    color: #3B3B3B
}
QListView::item{
    background: transparent;
    color: #3B3B3B;
    padding: 5px;
    outline: 0;
    border-radius: 4px;
}
QListView{
    outline: 0;
}

Is it possible to make it with clear css?

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Mika
  • 51
  • 4
  • No, it's not: according to the [QSS reference documentation](https://doc.qt.io/qt-5/stylesheet-reference.html), nor QMenu or abstract item views support those pseudo states. For QMenu you'd need to use a QProxyStyle (but then you will not be able to use style sheets anymore), for QComboBox you must use a custom delegate for the view. – musicamante Aug 10 '23 at 23:04

0 Answers0