mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
Add method to set line edit alignment in Qgs(Double)SpinBox
This commit is contained in:
parent
287f82286b
commit
bbf621411a
@ -117,6 +117,13 @@ Defines if the clear value should be the minimum or maximum values of the widget
|
||||
Returns the value used when clear() is called.
|
||||
|
||||
.. seealso:: :py:func:`setClearValue`
|
||||
%End
|
||||
|
||||
void setLineEditAlignment( Qt::Alignment alignment );
|
||||
%Docstring
|
||||
Set alignment in the embedded line edit widget
|
||||
|
||||
:param alignment:
|
||||
%End
|
||||
|
||||
virtual double valueFromText( const QString &text ) const;
|
||||
|
@ -117,6 +117,13 @@ Defines if the clear value should be the minimum or maximum values of the widget
|
||||
Returns the value used when clear() is called.
|
||||
|
||||
.. seealso:: :py:func:`setClearValue`
|
||||
%End
|
||||
|
||||
void setLineEditAlignment( Qt::Alignment alignment );
|
||||
%Docstring
|
||||
Set alignment in the embedded line edit widget
|
||||
|
||||
:param alignment:
|
||||
%End
|
||||
|
||||
virtual int valueFromText( const QString &text ) const;
|
||||
|
@ -34,7 +34,6 @@ QgsDoubleSpinBox::QgsDoubleSpinBox( QWidget *parent )
|
||||
// By default, group separator is off
|
||||
setLocale( QLocale( QgsApplication::locale( ) ) );
|
||||
setLineEdit( mLineEdit );
|
||||
mLineEdit->setAlignment( Qt::AlignRight );
|
||||
|
||||
QSize msz = minimumSizeHint();
|
||||
setMinimumSize( msz.width() + CLEAR_ICON_SIZE + 9 + frameWidth() * 2 + 2,
|
||||
@ -137,6 +136,11 @@ double QgsDoubleSpinBox::clearValue() const
|
||||
return mCustomClearValue;
|
||||
}
|
||||
|
||||
void QgsDoubleSpinBox::setLineEditAlignment( Qt::Alignment alignment )
|
||||
{
|
||||
mLineEdit->setAlignment( alignment );
|
||||
}
|
||||
|
||||
QString QgsDoubleSpinBox::stripped( const QString &originalText ) const
|
||||
{
|
||||
//adapted from QAbstractSpinBoxPrivate::stripped
|
||||
|
@ -126,6 +126,12 @@ class GUI_EXPORT QgsDoubleSpinBox : public QDoubleSpinBox
|
||||
*/
|
||||
double clearValue() const;
|
||||
|
||||
/**
|
||||
* Set alignment in the embedded line edit widget
|
||||
* \param alignment
|
||||
*/
|
||||
void setLineEditAlignment( Qt::Alignment alignment );
|
||||
|
||||
double valueFromText( const QString &text ) const override;
|
||||
QValidator::State validate( QString &input, int &pos ) const override;
|
||||
void paintEvent( QPaintEvent *e ) override;
|
||||
|
@ -47,12 +47,14 @@ QWidget *QgsRangeWidgetWrapper::createWidget( QWidget *parent )
|
||||
case QVariant::Double:
|
||||
{
|
||||
editor = new QgsDoubleSpinBox( parent );
|
||||
static_cast<QgsDoubleSpinBox *>( editor )->setLineEditAlignment( Qt::AlignRight );
|
||||
break;
|
||||
}
|
||||
case QVariant::Int:
|
||||
case QVariant::LongLong:
|
||||
default:
|
||||
editor = new QgsSpinBox( parent );
|
||||
static_cast<QgsSpinBox *>( editor )->setLineEditAlignment( Qt::AlignRight );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,6 @@ QgsSpinBox::QgsSpinBox( QWidget *parent )
|
||||
: QSpinBox( parent )
|
||||
{
|
||||
mLineEdit = new QgsSpinBoxLineEdit();
|
||||
mLineEdit->setAlignment( Qt::AlignRight );
|
||||
setLineEdit( mLineEdit );
|
||||
|
||||
QSize msz = minimumSizeHint();
|
||||
@ -133,6 +132,11 @@ int QgsSpinBox::clearValue() const
|
||||
return mCustomClearValue;
|
||||
}
|
||||
|
||||
void QgsSpinBox::setLineEditAlignment( Qt::Alignment alignment )
|
||||
{
|
||||
mLineEdit->setAlignment( alignment );
|
||||
}
|
||||
|
||||
int QgsSpinBox::valueFromText( const QString &text ) const
|
||||
{
|
||||
if ( !mExpressionsEnabled )
|
||||
|
@ -126,6 +126,12 @@ class GUI_EXPORT QgsSpinBox : public QSpinBox
|
||||
*/
|
||||
int clearValue() const;
|
||||
|
||||
/**
|
||||
* Set alignment in the embedded line edit widget
|
||||
* \param alignment
|
||||
*/
|
||||
void setLineEditAlignment( Qt::Alignment alignment );
|
||||
|
||||
int valueFromText( const QString &text ) const override;
|
||||
QValidator::State validate( QString &input, int &pos ) const override;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user