Qt5.6: How to disable the QComboBox's Up/Down arrows and show all items?



  • Hello,

    I'm creating a QComboBox with three items in it.

    When clicking on the combo box,

    In Qt4.8, they all show up at once in one vertical list.

    In Qt5.6, two items show and the third is hidden by the "down" arrow. The QComboBox only provides room to show two out of the three items. The user needs to mouse-scroll down or click the down arrow to show the third item.

    Is there a way to disable the up/down arrows and show the whole list at once?

    I use a a QStyledItemDelegate for the QComboBox::setItemDelegate().

    The code is as follows:

    cb = new QComboBox(this);
    cb->setItemDelegate( new QStyledItemDelegate);
    cb->setMaxCount(3);
    cb->setSizeAdjustPolicy(QComboBox::AdjustToContents);
    cb->setMaxVisibleItems(10);

    If I add more items, the problem persists, even if I increase the QComboBox::setMaxCount().

    If I use QItemDelegate instead of QStyledItemDelegate, all items are shown just fine, but I'd like to make this work with QStyledItemDelegate.

    Thanks in advance for any help!

    cg



  • Solution that works for me is to call unpolish and polish on combo box:

    auto cb = new QComboBox(this);
    cb->setItemDelegate( new QStyledItemDelegate);
    style()->unpolish(cb);
    style()->polish(cb);
    

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.