Skip to content

Commit

Permalink
Fix missing scrollbars in combo box for value map / relation
Browse files Browse the repository at this point in the history
If a value map widget or value relation widget has a combo box
with many options, the default behavior in Qt is not to add scrollbars,
only arrows at the top/bottom of the list. That however makes it
quite slow to scroll if the list of choices is long.

This fixes the issue for both value map and value relation.
If the list of choices is short that it fits the screen, no scrollbar
gets shown.
  • Loading branch information
wonder-sk authored and github-actions[bot] committed Feb 13, 2022
1 parent fb57979 commit af58cc8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/gui/editorwidgets/qgsvaluemapwidgetwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ void QgsValueMapWidgetWrapper::initWidget( QWidget *editor )
if ( mComboBox )
{
QgsValueMapConfigDlg::populateComboBox( mComboBox, config(), false );
mComboBox->view()->setVerticalScrollBarPolicy( Qt::ScrollBarAsNeeded );
connect( mComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ),
this, static_cast<void ( QgsEditorWidgetWrapper::* )()>( &QgsEditorWidgetWrapper::emitValueChanged ) );
}
Expand Down
1 change: 1 addition & 0 deletions src/gui/editorwidgets/qgsvaluerelationwidgetwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ void QgsValueRelationWidgetWrapper::initWidget( QWidget *editor )

if ( mComboBox )
{
mComboBox->view()->setVerticalScrollBarPolicy( Qt::ScrollBarAsNeeded );
connect( mComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ),
this, static_cast<void ( QgsEditorWidgetWrapper::* )()>( &QgsEditorWidgetWrapper::emitValueChanged ), Qt::UniqueConnection );
}
Expand Down

0 comments on commit af58cc8

Please sign in to comment.