-
Bug
-
Resolution: Out of scope
-
P3: Somewhat important
-
4.5.3, 4.6.2
-
None
With setEditable(true) and QCleanLooksStyle, QComboBox uses QComboMenuDelegate for the drop down list, which doesn't calculate the sizeHint basing on the content.
In the below example you can see that:
int viewWidth = view ()->sizeHintForColumn (0);
The value returned by sizeHintForColumn is very small since the delegate doesn't calculate the column size.
test case to reproduce the problem:
#include <QtGui> class MyComboBox : public QComboBox { public: MyComboBox (QWidget* parent):QComboBox(parent){}; virtual void showPopup (); }; void MyComboBox::showPopup () { if (model () && view ()) { QWidget* qw = dynamic_cast<QWidget*> (view ()->parent ()); if (qw) { int myWidth = size ().width (); int viewWidth = view ()->sizeHintForColumn (0); qWarning() << "sizehint for column:" << viewWidth << myWidth; if (count() > maxVisibleItems ()) { viewWidth += style()->pixelMetric (QStyle::PM_ScrollBarExtent); } int maxWidth = qMax (qMin (viewWidth, 500) + 5, myWidth); qWarning() << maxWidth; qw->setFixedWidth (maxWidth); } } QComboBox::showPopup(); } int main(int argc, char** argv) { QApplication app (argc, argv); app.setStyle (new QCleanlooksStyle); // bud case //app.setStyle (new QPlastiqueStyle); // good case MyComboBox* comboBox = new MyComboBox (NULL); comboBox->setEditable (true); comboBox->addItem ("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"); comboBox->addItem ("BBBBBBBBBBBBBBBBBBBBBBBBBBBB"); qWarning() << qApp->style(); comboBox->show(); app.exec(); }