Skip to content

Commit

Permalink
Ensure that clear button is shown for QgsSpinBox/DoubleSpinBox
Browse files Browse the repository at this point in the history
Previously the clear button might not show if the value of the
widget was set while its signals were blocked.
  • Loading branch information
nyalldawson committed Jan 19, 2015
1 parent 1310b87 commit 0cde4f1
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions python/gui/editorwidgets/qgsdoublespinbox.sip
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,5 @@ class QgsDoubleSpinBox : QDoubleSpinBox
protected:
virtual void resizeEvent( QResizeEvent* event );
virtual void changeEvent( QEvent* event );
virtual void paintEvent( QPaintEvent* event );
};
1 change: 1 addition & 0 deletions python/gui/editorwidgets/qgsspinbox.sip
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,5 @@ class QgsSpinBox : QSpinBox
protected:
virtual void resizeEvent( QResizeEvent* event );
virtual void changeEvent( QEvent* event );
virtual void paintEvent( QPaintEvent* event );
};
6 changes: 6 additions & 0 deletions src/gui/editorwidgets/qgsdoublespinbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) );
Expand Down
1 change: 1 addition & 0 deletions src/gui/editorwidgets/qgsdoublespinbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
6 changes: 6 additions & 0 deletions src/gui/editorwidgets/qgsspinbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) );
Expand Down
1 change: 1 addition & 0 deletions src/gui/editorwidgets/qgsspinbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down

0 comments on commit 0cde4f1

Please sign in to comment.