开发者

Qt - Using QEasingCurve's output for something other than an Animation

I wonder could anyone be of help.

If for example I wanted to use the output of the QEasingcurve for another purpose other than driving a QAnimation, is this possible? For example, if I had a numerical read out on my GUI that I wanted to grow, overshoot and bounce back into place could I use the QEasingcurve for this purpose?

I have used Qt for quite a while but have never dabbled with any of these parts of i开发者_JAVA百科t - I am trying to work it out but cannot, so thought I'd ask here.


I am not sure I understand correctly what you want to display, but from what I understand, using QPropertyAnimation is probably the way to go.

However, to answer your question, you can of course use QEasingCurve in a standalone manner, you just need to use the valueForProgress(qreal progress) member function.


Hey - Just wanted to update with how I carried this out in case anyone looks it up in the future.

void RPM::updateGauge(float speed)
{
  easing = new QEasingCurve(QEasingCurve::OutElastic);

  easing->setAmplitude(1.0);

  currentPosition = (float)ui->svgdial_currentSpeed->value();
  newPosition = speed;
  difference = newPosition - currentPosition;

  interval = 0.0;

  timer = new QTimer(this);

  connect(timer, SIGNAL(timeout()), this, SLOT(doGaugeMovement()));

  timer->start(60);

}

void RPM::doGaugeMovement()
{
  interval+=0.01;
  ui->svgdial_currentSpeed->setValue(currentPosition + ( difference * easing-
                                           >valueForProgress( interval ) ) );


 if(interval >= 1.0)
 {
     timer->stop();
 }

}

Simply used a timer to update the gauge slowly, pulling the valueForProgress result for its new position each time.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜