Search code examples
pythonpyqtpyqt4qcombobox

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.


Solution

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

    combo_type.setStyleSheet('''*    
    QComboBox QAbstractItemView 
        {
        min-width: 150px;
        }
    ''')