Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Not getting all QTimer timeouts
Qt 6.11 is out! See what's new in the release blog

Not getting all QTimer timeouts

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 347 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ajaxcrypto
    wrote on last edited by
    #1

    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
    timer->setType(Qt::PreciseTimer);
    QObject::connect(timer, &QTimer::timeout, this, [this, timer] {
        auto done = this->updateColorForColumnSpecified();
        if (done) timer->stop();
    });
    timer->start();
    

    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?

    btseB 1 Reply Last reply
    0
    • A ajaxcrypto

      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
      timer->setType(Qt::PreciseTimer);
      QObject::connect(timer, &QTimer::timeout, this, [this, timer] {
          auto done = this->updateColorForColumnSpecified();
          if (done) timer->stop();
      });
      timer->start();
      

      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?

      btseB Offline
      btseB Offline
      btse
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0
      • A Offline
        A Offline
        ajaxcrypto
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved