diff --git a/src/libkdepim/widgets/kcheckcombobox.h b/src/libkdepim/widgets/kcheckcombobox.h --- a/src/libkdepim/widgets/kcheckcombobox.h +++ b/src/libkdepim/widgets/kcheckcombobox.h @@ -152,6 +152,11 @@ */ Q_REQUIRED_RESULT QStringList checkedItems(int role = Qt::DisplayRole) const; + /** + * Reimplemented to take the combo text width into account + */ + QSize sizeHint() const override; + public Q_SLOTS: /** * Sets the currently selected items. Items that are not found in the model diff --git a/src/libkdepim/widgets/kcheckcombobox.cpp b/src/libkdepim/widgets/kcheckcombobox.cpp --- a/src/libkdepim/widgets/kcheckcombobox.cpp +++ b/src/libkdepim/widgets/kcheckcombobox.cpp @@ -368,4 +368,19 @@ } } +QSize KCheckComboBox::sizeHint() const +{ + // sizeHint based on the items in the combo + QSize size = KComboBox::sizeHint(); + + // Ensure that we can read the complete lineedit contents + QSize lineeditsh = lineEdit()->sizeHint(); + QStyleOptionComboBox opt; + initStyleOption(&opt); + lineeditsh = style()->sizeFromContents(QStyle::CT_ComboBox, &opt, lineeditsh, this); // dropdown indicator etc. + + size.rwidth() = qMax(size.width(), lineeditsh.width()); + return size; +} + #include "moc_kcheckcombobox.cpp"