Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Qt Quick 3D - Robot Arm Example

// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause

#include "animatedparam.h"

#include <QVariantAnimation>

AnimatedParam::AnimatedParam(QObject *parent) : QVariantAnimation(parent)
{
    setDuration(1500);
    setEasingCurve(QEasingCurve::InOutCubic);

    connect(this, &QVariantAnimation::valueChanged, this, &AnimatedParam::valueChanged);
    connect(this, &QAbstractAnimation::stateChanged, this, [this](QAbstractAnimation::State newState, QAbstractAnimation::State oldState) {
        m_isRunning = (newState == QAbstractAnimation::Running);
    });
}

int AnimatedParam::value() const
{
    return currentValue().toInt();
}

void AnimatedParam::setValue(int newValue)
{
    stop();
    setStartValue(value());
    setEndValue(newValue);
    start();
}

bool AnimatedParam::isRunning() const
Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded