Skip to content

Commit 0cde4f1

Browse files
committedJan 19, 2015
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.
1 parent 1310b87 commit 0cde4f1

File tree

6 files changed

+16
-0
lines changed

6 files changed

+16
-0
lines changed
 

‎python/gui/editorwidgets/qgsdoublespinbox.sip

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,5 @@ class QgsDoubleSpinBox : QDoubleSpinBox
5757
protected:
5858
virtual void resizeEvent( QResizeEvent* event );
5959
virtual void changeEvent( QEvent* event );
60+
virtual void paintEvent( QPaintEvent* event );
6061
};

‎python/gui/editorwidgets/qgsspinbox.sip

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,5 @@ class QgsSpinBox : QSpinBox
5757
protected:
5858
virtual void resizeEvent( QResizeEvent* event );
5959
virtual void changeEvent( QEvent* event );
60+
virtual void paintEvent( QPaintEvent* event );
6061
};

‎src/gui/editorwidgets/qgsdoublespinbox.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ void QgsDoubleSpinBox::changeEvent( QEvent *event )
6363
mClearButton->setVisible( shouldShowClearForValue( value() ) );
6464
}
6565

66+
void QgsDoubleSpinBox::paintEvent( QPaintEvent *event )
67+
{
68+
mClearButton->setVisible( shouldShowClearForValue( value() ) );
69+
QDoubleSpinBox::paintEvent( event );
70+
}
71+
6672
void QgsDoubleSpinBox::changed( const double& value )
6773
{
6874
mClearButton->setVisible( shouldShowClearForValue( value ) );

‎src/gui/editorwidgets/qgsdoublespinbox.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ class GUI_EXPORT QgsDoubleSpinBox : public QDoubleSpinBox
8282
protected:
8383
virtual void resizeEvent( QResizeEvent* event ) override;
8484
virtual void changeEvent( QEvent* event ) override;
85+
virtual void paintEvent( QPaintEvent* event ) override;
8586

8687
private slots:
8788
void changed( const double &value );

‎src/gui/editorwidgets/qgsspinbox.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ void QgsSpinBox::changeEvent( QEvent *event )
6363
mClearButton->setVisible( shouldShowClearForValue( value() ) );
6464
}
6565

66+
void QgsSpinBox::paintEvent( QPaintEvent *event )
67+
{
68+
mClearButton->setVisible( shouldShowClearForValue( value() ) );
69+
QSpinBox::paintEvent( event );
70+
}
71+
6672
void QgsSpinBox::changed( const int& value )
6773
{
6874
mClearButton->setVisible( shouldShowClearForValue( value ) );

‎src/gui/editorwidgets/qgsspinbox.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ class GUI_EXPORT QgsSpinBox : public QSpinBox
8181
protected:
8282
virtual void resizeEvent( QResizeEvent* event ) override;
8383
virtual void changeEvent( QEvent* event ) override;
84+
virtual void paintEvent( QPaintEvent* event ) override;
8485

8586
private slots:
8687
void changed( const int& value );

0 commit comments

Comments
 (0)
Please sign in to comment.