1 #include "QDS_SpinBox.h"
3 #include <QtxIntSpinBox.h>
5 #include <qvalidator.h>
10 QDS_SpinBox::QDS_SpinBox( const QString& id, QWidget* parent, const int flags, const QString& comp )
11 : QDS_Datum( id, parent, flags, comp )
18 QDS_SpinBox::~QDS_SpinBox()
23 Returns string from QSpinBox widget.
25 QString QDS_SpinBox::getString() const
28 QtxIntSpinBox* aSpinBox = spinBox();
29 if ( aSpinBox && !aSpinBox->isCleared() )
31 res = aSpinBox->text();
32 if ( !aSpinBox->suffix().isEmpty() )
33 res.remove( res.find( aSpinBox->suffix() ), aSpinBox->suffix().length() );
34 if ( !aSpinBox->prefix().isEmpty() )
35 res.remove( res.find( aSpinBox->prefix() ), aSpinBox->prefix().length() );
41 Sets the string into QSpinBox widget.
43 void QDS_SpinBox::setString( const QString& txt )
48 spinBox()->setCleared( txt.isEmpty() );
50 spinBox()->setValue( txt.toInt() );
54 Returns pointer to QSpinBox widget.
56 QtxIntSpinBox* QDS_SpinBox::spinBox() const
58 return ::qt_cast<QtxIntSpinBox*>( controlWidget() );
62 Create QSpinBox widget as control subwidget.
64 QWidget* QDS_SpinBox::createControl( QWidget* parent )
66 QtxIntSpinBox* aSpinBox = new QtxIntSpinBox( parent );
67 aSpinBox->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
68 connect( aSpinBox, SIGNAL( valueChanged( int ) ), this, SLOT( onValueChanged( int ) ) );
73 Notify about text changing in spin box.
75 void QDS_SpinBox::onValueChanged( int val )
78 QString str = QString::number( val );
80 emit paramChanged( str );
84 Sets the increment step.
86 void QDS_SpinBox::setStep( const int step )
89 spinBox()->setLineStep( step );
93 Returns the increment step.
95 int QDS_SpinBox::step() const
99 s = spinBox()->lineStep();
104 This method is redefined from ancestor class to perform own initialization ( suffix, prefix, etc ).
106 void QDS_SpinBox::unitSystemChanged( const QString& system )
108 QDS_Datum::unitSystemChanged( system );
110 QSpinBox* sb = spinBox();
113 delete sb->validator();
114 QValidator* valid = validator();
115 sb->setValidator( valid );
117 sb->setSuffix( suffix() );
118 sb->setPrefix( prefix() );
119 sb->setMinValue( minValue().toInt() );
120 sb->setMaxValue( maxValue().toInt() );