Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.12.5
-
None
Description
An editable QComboBox popup can have a wrong height depending on the order in which the combo box is initialized.
1. view() is called (or any other method that implicitly calls the private viewContainer()
2. setLineEdit(...) without a preceding setEditable(true)
I think this is because viewControler()->updateTopBottomMargin() is not called in this case.
#include <stdlib.h> #include <QComboBox> #include <QApplication> #include <QLineEdit> #include <QtDebug> int main(int argc, char *argv[]) { /* "fusion" or "windows" styles do not exibit this. * Probable cause: different cb->style()->pixelMetric(QStyle::PM_MenuVMargin, nullptr, cb) */ // setenv("QT_STYLE_OVERRIDE", "fusion", 0); QApplication a(argc, argv); QComboBox *cb = new QComboBox(); /* Cause the view to be created. * Any thing that implicitly causes the `viewControler()` to be called * can be used here to replicate this * e.g. ->setSizeAdjustPolicy(QComboBox::AdjustToMinimumContentsLength); */ cb->view(); /* setting a line edit implicitly sets editable property but does not * update the view the way setEditable(true) does*/ cb->setLineEdit(new QLineEdit()); /* this is a no-op; does not call viewControler()->updateTopBottomMargin(); */ cb->setEditable(true); cb->setInsertPolicy(QComboBox::InsertAtTop); cb->addItem("First"); cb->show(); return a.exec(); }