Ensure that clear button is shown for QgsSpinBox/DoubleSpinBox

Previously the clear button might not show if the value of the
widget was set while its signals were blocked.
This commit is contained in:
Nyall Dawson 2015-01-19 23:23:59 +11:00
parent 1310b87081
commit 0cde4f103b
6 changed files with 16 additions and 0 deletions

View File

@ -57,4 +57,5 @@ class QgsDoubleSpinBox : QDoubleSpinBox
protected:
virtual void resizeEvent( QResizeEvent* event );
virtual void changeEvent( QEvent* event );
virtual void paintEvent( QPaintEvent* event );
};

View File

@ -57,4 +57,5 @@ class QgsSpinBox : QSpinBox
protected:
virtual void resizeEvent( QResizeEvent* event );
virtual void changeEvent( QEvent* event );
virtual void paintEvent( QPaintEvent* event );
};

View File

@ -63,6 +63,12 @@ void QgsDoubleSpinBox::changeEvent( QEvent *event )
mClearButton->setVisible( shouldShowClearForValue( value() ) );
}
void QgsDoubleSpinBox::paintEvent( QPaintEvent *event )
{
mClearButton->setVisible( shouldShowClearForValue( value() ) );
QDoubleSpinBox::paintEvent( event );
}
void QgsDoubleSpinBox::changed( const double& value )
{
mClearButton->setVisible( shouldShowClearForValue( value ) );

View File

@ -82,6 +82,7 @@ class GUI_EXPORT QgsDoubleSpinBox : public QDoubleSpinBox
protected:
virtual void resizeEvent( QResizeEvent* event ) override;
virtual void changeEvent( QEvent* event ) override;
virtual void paintEvent( QPaintEvent* event ) override;
private slots:
void changed( const double &value );

View File

@ -63,6 +63,12 @@ void QgsSpinBox::changeEvent( QEvent *event )
mClearButton->setVisible( shouldShowClearForValue( value() ) );
}
void QgsSpinBox::paintEvent( QPaintEvent *event )
{
mClearButton->setVisible( shouldShowClearForValue( value() ) );
QSpinBox::paintEvent( event );
}
void QgsSpinBox::changed( const int& value )
{
mClearButton->setVisible( shouldShowClearForValue( value ) );

View File

@ -81,6 +81,7 @@ class GUI_EXPORT QgsSpinBox : public QSpinBox
protected:
virtual void resizeEvent( QResizeEvent* event ) override;
virtual void changeEvent( QEvent* event ) override;
virtual void paintEvent( QPaintEvent* event ) override;
private slots:
void changed( const int& value );