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