Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Pause and restart timerEvent



  • I see some example codes to pause the timer in Snake game such as:

    void pause() {
        int remaining = dataTimer.remainingTime();
        dataTimer.stop();
        dataTimer.setInterval(remaining);
    }
    
    void resume() {
        dataTimer.start();
    }
    

    Since I use timerEvent, I use

    timerId = startTimer(DELAY)
    killTimer(timerId);
    

    Is there anyway to convert the 1st code for timerEvent? Any hint?



  • @antran96

    I don't think so, QObject class only provides the basic of timer supports. If you need to set Interval or other features of QTimer, you should use a QTimer Object instead of use QObject Timer.


Log in to reply