QTimer issue on iOS



  • Hi!

    As part of my iOS app, I am using a QTimer object to call a method every X milliseconds. Nothing out of this world:

       timer->start(milliseconds);
    

    I have been testing the same code either in Android and Windows and the performance of the timer is accurate. My problem occurs specifically in iOS, where the method called by the timer is executed with a constant interval of time, in despite of the value I set for the milliseconds variable.

    Is there any reference about considerations of using QTimer variables or real time resources in iOS?

    Thanks.


  • Qt Champions 2016

    @xtingray how are you setting your milliseconds exactly ?



  • My implementation is about a player of a sequence of images simulating an animation reproducer.

    play(int fps) {
       int milliseconds = 1000/fps;
       timer->start(milliseconds);
    }
    

    fps is a value between 1 and 50. As I said before this works perfect in Android and Windows.


  • Lifetime Qt Champion

    Hi,

    You can try to change the timer type for Qt::PreciseTimer check the implication for doing so.



  • I tried your advice with no luck:

       timer = new QTimer(this);
       timer->setTimerType(Qt::PreciseTimer);
       connect(timer, &QTimer::timeout, this, &Reproducer::play);
    

    The difference is quite evident comparing Android performance vs iOS. Same code.


  • Qt Champions 2016

    @xtingray said in QTimer issue on iOS:

    My implementation is about a player of a sequence of images simulating an animation reproducer.

    play(int fps) {
       int milliseconds = 1000/fps;
       timer->start(milliseconds);
    }
    

    looks good. I remember problems where - in qml - setting the timeout as x*60 or so could cause problems
    have overlooked that you're doing it from c++

    will verify if my timers are working correct on iOS


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.