Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QComboBox adjust drop down width

Not sure why I cant get it to work, so maybe one of you will be able to see my mistake... :

combo_type = QComboBox()
combo_type.setMaximumWidth(50)
combo_type.addItems(["TEsst1111","TEsst11111111111111","TEsst1111111111111111111111111"])
combo_type.setStyleSheet('''*
    QComboBox QAbstractItemView::item
    {
    min-width: 6000px;
    }
''')

The idea is so that widget in UI has 50 width but when drop down and open I can read the list, sadly the stylesheet override don't change the drop down width making it 50 and unreadable...

Thanks.

like image 757
Dariusz Avatar asked May 30 '26 21:05

Dariusz


1 Answers

Sorted... it was naming error. Correct answer posted below.

combo_type.setStyleSheet('''*    
QComboBox QAbstractItemView 
    {
    min-width: 150px;
    }
''')
like image 87
Dariusz Avatar answered Jun 02 '26 09:06

Dariusz