Skip to content

Commit

Permalink
Fix int range widget minimum value
Browse files Browse the repository at this point in the history
The int range widget so far assigned NULL to the minimum value when allowNull was activated. This made it impossible to enter the minimum value into a range widget.

This also fixes some signals which in case of a NULL value would emit a slightly-below-minimum value for double and int spinboxes.

Fix #18297
  • Loading branch information
m-kuhn committed Mar 1, 2018
1 parent 752dc7d commit 0b49a83
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/gui/editorwidgets/qgsrangewidgetwrapper.cpp
Expand Up @@ -128,24 +128,27 @@ void QgsRangeWidgetWrapper::initWidget( QWidget *editor )
mDoubleSpinBox->setSuffix( config( QStringLiteral( "Suffix" ) ).toString() );

connect( mDoubleSpinBox, static_cast < void ( QDoubleSpinBox::* )( double ) > ( &QDoubleSpinBox::valueChanged ),
this, [ = ]( double value ) { emit valueChanged( value ); } );
this, [ = ]( double ) { emitValueChanged(); } );
}
else if ( mIntSpinBox )
{
QgsSpinBox *qgsWidget = qobject_cast<QgsSpinBox *>( mIntSpinBox );
if ( qgsWidget )
qgsWidget->setShowClearButton( allowNull );
int minval = min.toInt();
if ( allowNull )
{
int minval = min.toInt();
int stepval = step.toInt();
minval -= stepval;
mIntSpinBox->setValue( minval );
mIntSpinBox->setSpecialValueText( QgsApplication::nullRepresentation() );
}
setupIntEditor( min, max, step, mIntSpinBox, this );
setupIntEditor( minval, max, step, mIntSpinBox, this );
if ( config( QStringLiteral( "Suffix" ) ).isValid() )
mIntSpinBox->setSuffix( config( QStringLiteral( "Suffix" ) ).toString() );

connect( mIntSpinBox, static_cast < void ( QSpinBox::* )( int ) > ( &QSpinBox::valueChanged ),
this, [ = ]( int ) { emitValueChanged(); } );
}
else
{
Expand Down

0 comments on commit 0b49a83

Please sign in to comment.