+ implement key up/down for input field, fix wheel event

This commit is contained in:
wmayer 2014-04-02 12:22:28 +02:00
parent 25d0242f97
commit f2a922bdf2
2 changed files with 28 additions and 13 deletions

View File

@ -366,21 +366,35 @@ void InputField::selectNumber(void)
}
void InputField::wheelEvent ( QWheelEvent * event )
void InputField::keyPressEvent(QKeyEvent *event)
{
int numDegrees = event->delta() / 8;
int numSteps = numDegrees / 15;
switch (event->key()) {
case Qt::Key_Up:
{
double val = actUnitValue + StepSize;
this->setText( QString::fromUtf8("%L1 %2").arg(val).arg(actUnitStr));
event->accept();
}
break;
case Qt::Key_Down:
{
double val = actUnitValue - StepSize;
this->setText( QString::fromUtf8("%L1 %2").arg(val).arg(actUnitStr));
event->accept();
}
break;
default:
QLineEdit::keyPressEvent(event);
break;
}
}
double val = actUnitValue + numSteps;
this->setText( QString::fromUtf8("%L1 %2").arg(val).arg(actUnitStr));
//if (event->orientation() == Qt::Horizontal) {
// scrollHorizontally(numSteps);
//} else {
// scrollVertically(numSteps);
//}
event->accept();
void InputField::wheelEvent (QWheelEvent * event)
{
double step = event->delta() > 0 ? StepSize : -StepSize;
double val = actUnitValue + step;
this->setText( QString::fromUtf8("%L1 %2").arg(val).arg(actUnitStr));
event->accept();
}
// --------------------------------------------------------------------

View File

@ -139,6 +139,7 @@ protected Q_SLOTS:
void updateIconLabel(const QString& text);
protected:
virtual void keyPressEvent(QKeyEvent * event);
virtual void wheelEvent(QWheelEvent * event);
virtual void contextMenuEvent(QContextMenuEvent * event);
virtual void resizeEvent(QResizeEvent*);