Details
-
Suggestion
-
Resolution: Cannot Reproduce
-
P3: Somewhat important
-
4.1.0
-
None
Description
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.