Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
5.8.0
-
* Board: Toradex Apalis iMX6
* OS: Linux
* Image: Apalis_iMX6_LinuxImageV2.6Beta2_20160630.tar.bz2
* Qt: Self-compiled with X11 support
Description
Any animation completes quicker than declared in two times.
E.g. when animation duration is 5000 msecs, then it completes in ~2700 msecs. Please see following code (also see an example project from attach).
= main.qml =
iimport QtQuick 2.4 Rectangle { id: root color: "red" anchors.fill: parent Rectangle { color: "green"; width: 50; height: 50; NumberAnimation on x { running: true; from: 0; to: 1000; duration: 5000; onStopped: { calculator.qmlAnimationElapsed(); start(); } } } Timer { interval: 1000; running: true; repeat: true onTriggered: calculator.qmlTimerElapsed(); } }
= main.cpp =
#include <QGuiApplication> #include <QQuickView> #include <QQmlContext> #include <QElapsedTimer> #include <QTimer> #include <QDebug> class Calculator : public QObject { Q_OBJECT public: explicit Calculator(QObject *parent = nullptr) : QObject(parent) { m_animation.start(); m_timer.start(); } Q_INVOKABLE void qmlAnimationElapsed() { qDebug() << "QML animation elapsed:" << m_animation.elapsed(); m_animation.start(); } Q_INVOKABLE void qmlTimerElapsed() { qDebug() << "QML timer elapsed:" << m_timer.elapsed(); m_timer.start(); } private: QElapsedTimer m_animation; QElapsedTimer m_timer; }; int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); QElapsedTimer elapsedTimer; QTimer timer; QGuiApplication::connect(&timer, &QTimer::timeout, [&elapsedTimer]() { qDebug() << "C++ timer elapsed:" << elapsedTimer.elapsed(); elapsedTimer.start(); }); elapsedTimer.start(); timer.start(1000); Calculator calculator; QQuickView view; view.rootContext()->setContextProperty("calculator", &calculator); view.setSource(QUrl(QStringLiteral("qrc:/main.qml"))); view.setResizeMode(QQuickView::SizeRootObjectToView); view.showFullScreen(); return app.exec(); } #include "main.moc"
Debug output:
C++ timer elapsed: 1125
QML timer elapsed: 1597
QML timer elapsed: 447
C++ timer elapsed: 974
QML timer elapsed: 462
QML timer elapsed: 454
C++ timer elapsed: 1025
QML animation elapsed: 3412
QML timer elapsed: 450
QML timer elapsed: 452
C++ timer elapsed: 1000
QML timer elapsed: 451
QML timer elapsed: 452
C++ timer elapsed: 1001
QML timer elapsed: 456
QML animation elapsed: 2278
QML timer elapsed: 464
C++ timer elapsed: 998
QML timer elapsed: 454
QML timer elapsed: 454
QML timer elapsed: 451
C++ timer elapsed: 999
QML timer elapsed: 452
QML animation elapsed: 2270
QML timer elapsed: 457
C++ timer elapsed: 999
QML timer elapsed: 454
QML timer elapsed: 454
The QTimer works as expected, but the QML's timer lies!!!
Attachments
Issue Links
- relates to
-
QTBUG-46075 QML inconsisten animation speed and durations
- Closed
-
QTBUG-56687 Qml property animations inaccurate
- Closed
-
QTBUG-96774 Enable use of high frame rate with vsync disabled without drawbacks mentioned in QTBUG-91923
- Open