Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-67

QComboBox: cannot be smaller than the popup view

XMLWordPrintable

    • Icon: Suggestion Suggestion
    • Resolution: Cannot Reproduce
    • Icon: P3: Somewhat important P3: Somewhat important
    • Some future release
    • 4.1.0
    • Widgets: Itemviews
    • None

      With Qt 3, the example below shows a combobox that itself is not large enough to display the current item, but the drop down is large enough to show all the strings. This is sometimes the desired look, but with Qt 4 it is not possible to achieve this through a straight-forward API.

      #include <qapplication.h>
      #include <qcombobox.h>
      #include <qlayout.h>
      #include <qlistbox.h>
      
      int main(int argc, char *argv[])
      {
          QApplication app(argc, argv);
      
          QWidget widget;
          QHBoxLayout hbox(&widget);
          QComboBox cb(&widget);
      
          cb.listBox()->setVariableWidth(true);
      
          hbox.addWidget(&cb);
          widget.show();
      
          QStringList entries;
          entries << "4001 Some Text" << "4002 Some more Text" << "4011 Some really long text";
          cb.insertStringList(entries);
      
          return app.exec();
      }
      

      Having a QComboBox::SizeAdjustPolicy value that would make QComboBox not grow on insertion, but would give the popup enough size to display the values would be a good solution.

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            vhilshei Volker Hilsheimer
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes