Not getting all QTimer timeouts

  • My goal is to set a color to a specified column of a QTableWidget and then it's alpha value to 0 (opacity) in about 500ms. Hence, I wrote a QTimer with 5ms interval and PreciseTimer type. While the timer does work, I only get 2 events at around 200ms and 360ms instead of 100 timeouts spread over 500ms. What could possible trigger this behavior?

    auto timer = new QTimer(this);
    timer->setInterval(5); // Take 100 steps after 5ms each
    QObject::connect(timer, &QTimer::timeout, this, [this, timer] {
        auto done = this->updateColorForColumnSpecified();
        if (done) timer->stop();

    I always seem to get only 2 timeouts at precisely those intervals. This ruins the "fade" effect of the column. What should I look into?

  • @ajaxcrypto How are you checking for the timeout intervals? What happens if you place a debug message directly in the slot.

  • Increasing the interval to 10ms seems to work perfectly. (The fade effect in turn completes in about ~1000ms).

Log in to reply