I have an app written in QT that uses QTimer. It's basically a game and all the actions are controlled by the timer. Game includes the ability to increase\decrease the game speed. The code for increasing the speed is
timerValue -= speedUpValue;
if (timerValue < maxSpeed) {
timerValue = maxSpeed;
}
timer -> setInterval(timerValue);
speedUpValueand maxSpeed are constants. Almost the same code is used for decreasing the speed. The problem is that setInterval resets the internal timer and therefore if you keep rapidly increasing or decreasing the speed game eventually never proceeds because remainingTime is constantly being reset. Is there a way to set remainingTime manually or change the interval without resetting it?