Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt5.6: How to disable the QComboBox's Up/Down arrows and show all items?
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
qcombobox
2 Posts 2 Posters 3.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • cgripeosC Offline
    cgripeosC Offline
    cgripeos
    wrote on last edited by cgripeos
    #1

    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

    1 Reply Last reply
    0
    • R Offline
      R Offline
      rzhurov
      wrote on last edited by
      #2

      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);
      
      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved