From a095ac534ad8c9f38329fee601c9dc397e273fe6 Mon Sep 17 00:00:00 2001 From: vsv Date: Thu, 14 May 2020 18:47:30 +0300 Subject: [PATCH] Issue #3250: Adapt a list of parameters to a width of parameter strings --- src/ModuleBase/ModuleBase_ParamSpinBox.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/ModuleBase/ModuleBase_ParamSpinBox.cpp b/src/ModuleBase/ModuleBase_ParamSpinBox.cpp index fcfbf2949..8107a46a8 100644 --- a/src/ModuleBase/ModuleBase_ParamSpinBox.cpp +++ b/src/ModuleBase/ModuleBase_ParamSpinBox.cpp @@ -81,6 +81,17 @@ void ModuleBase_ParamSpinBox::setCompletionList(QStringList& theList) theList.removeDuplicates(); theList.sort(); myCompleterModel->setStringList(theList); + + QAbstractItemView* aPopup = myCompleter->popup(); + QFontMetrics aMetric = aPopup->fontMetrics(); + int aWidth = 0; + QRect aRect; + foreach(QString aStr, theList) { + aRect = aMetric.boundingRect(aStr); + if (aRect.width() > aWidth) + aWidth = aRect.width(); + } + aPopup->setMinimumWidth(aWidth + 25); } /*! -- 2.39.2