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. How to make QTimer fire immediately on start?
QtWS25 Last Chance

How to make QTimer fire immediately on start?

Scheduled Pinned Locked Moved Unsolved General and Desktop
qtimer
2 Posts 2 Posters 1.1k Views
  • 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.
  • S Offline
    S Offline
    schrute
    wrote on last edited by
    #1

    I need to have a QTimer that fires every 10s, however, the first invocation of the slot is 10s after the timer is started.

    QTimer timer;
    connect(timer, SIGNAL(timeout()), this, SLOT(timeoutFired()));
    timer.setInterval(10000);
    timer.start();
    

    Is it possible to have the timer fire immediately on calling start() and have the rest of the notifications after 10s?

    JoeCFDJ 1 Reply Last reply
    0
    • S schrute

      I need to have a QTimer that fires every 10s, however, the first invocation of the slot is 10s after the timer is started.

      QTimer timer;
      connect(timer, SIGNAL(timeout()), this, SLOT(timeoutFired()));
      timer.setInterval(10000);
      timer.start();
      

      Is it possible to have the timer fire immediately on calling start() and have the rest of the notifications after 10s?

      JoeCFDJ Offline
      JoeCFDJ Offline
      JoeCFD
      wrote on last edited by JoeCFD
      #2

      @schrute

      QTimer timer;
      connect(timer, SIGNAL(timeout()), this, SLOT(timeoutFired()));
      timer.setInterval(10000);
      timer.start();
      timeoutFired();====>call this func to start right away
      
      1 Reply Last reply
      2

      • Login

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