14 #include <qlineedit.h> 15 #include <qvalidator.h> 73 QHBoxLayout *layout =
new QHBoxLayout(
this );
74 layout->setSpacing( 0 );
75 layout->setMargin( 0 );
81 btn->setFocusPolicy( Qt::NoFocus );
82 layout->addWidget( btn );
84 connect( btn, SIGNAL( released() ), SLOT(
btnReleased() ) );
85 connect( btn, SIGNAL( clicked() ), SLOT(
btnClicked() ) );
104 btn->setFocusPolicy( Qt::NoFocus );
105 layout->addWidget( btn );
107 connect( btn, SIGNAL( released() ), SLOT(
btnReleased() ) );
108 connect( btn, SIGNAL( clicked() ), SLOT(
btnClicked() ) );
119 QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed ) );
122 setFocusPolicy( Qt::StrongFocus );
206 value = qBound( vmin, value, vmax );
242 max = qMax( min, max );
368 if (
i < numButtons )
472 bool converted =
false;
486 if ( event->type() == QEvent::PolishRequest )
496 return QWidget::event( event );
523 bool accepted =
true;
525 switch ( event->key() )
529 if ( event->modifiers() & Qt::ControlModifier )
537 if ( event->modifiers() & Qt::ControlModifier )
554 case Qt::Key_PageDown:
561 if ( event->modifiers() & Qt::ShiftModifier )
564 if ( event->key() == Qt::Key_PageDown )
565 increment = -increment;
581 QWidget::keyPressEvent ( event );
598 if ( event->modifiers() & Qt::ControlModifier )
603 if ( event->modifiers() & Qt::ShiftModifier )
616 const int wheel_delta = 120;
619 int delta =
event->delta();
620 if ( delta >= 2 * wheel_delta )
638 stepSize = qMax( stepSize, 1.0e-10 * ( max - min ) );
645 const double range = max - min;
649 value += ::ceil( ( min - value ) / range ) * range;
651 else if ( value > max )
653 value -= ::ceil( ( value - max ) / range ) * range;
658 value = qBound( min, value, max );
661 value = min + qRound( ( value - min ) / stepSize ) * stepSize;
663 if ( stepSize > 1e-12 )
665 if ( qFuzzyCompare( value + 1.0, 1.0 ) )
670 else if ( qFuzzyCompare( value, max ) )
726 text.setNum( number );
757 int w = tmp.setNum(
minimum() ).length();
758 int w1 = tmp.setNum(
maximum() ).length();
771 w = fm.width( tmp ) + 2;
773 w += 2 * style()->pixelMetric( QStyle::PM_DefaultFrameWidth );
778 w += QWidget::sizeHint().width() -
d_data->
valueEdit->sizeHint().width();
780 const int h = qMin( QWidget::sizeHint().height(),
782 return QSize( w, h );
void textChanged()
Set from lineedit.
QwtArrowButton * buttonUp[ButtonCnt]
void valueChanged(double value)
void setMinimum(double min)
void btnClicked()
Button clicked.
virtual ~QwtCounter()
Destructor.
QwtArrowButton * buttonDown[ButtonCnt]
void buttonReleased(double value)
void setStepButton1(int nSteps)
void setNumButtons(int n)
void setWrapping(bool)
En/Disable wrapping.
void setStepButton2(int nSteps)
void incrementValue(int numSteps)
Button intended for medium steps.
Button intended for minor steps.
void updateButtons()
Update buttons according to the current value.
void setMaximum(double max)
void setSingleStep(double s)
Set the step size of the counter.
void setRange(double min, double max)
Set the minimum and maximum values.
virtual void wheelEvent(QWheelEvent *)
void setIncSteps(QwtCounter::Button btn, int nSteps)
virtual void keyPressEvent(QKeyEvent *)
virtual bool event(QEvent *)
int incSteps(QwtCounter::Button btn) const
TFSIMD_FORCE_INLINE const tfScalar & w() const
virtual QSize sizeHint() const
A size hint.
Button intended for large steps.
void setValue(double)
Set a new value without adjusting to the step raster.
void btnReleased()
Button released.
void setReadOnly(bool)
Allow/disallow the user to manually edit the value.
void setStepButton3(int nSteps)
double singleStep() const
QwtCounter(QWidget *parent=NULL)