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. Pause and restart timerEvent

Pause and restart timerEvent

Scheduled Pinned Locked Moved Unsolved General and Desktop
2 Posts 2 Posters 522 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.
  • A Offline
    A Offline
    antran96
    wrote on last edited by
    #1

    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?

    KillerSmathK 1 Reply Last reply
    0
    • A antran96

      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?

      KillerSmathK Offline
      KillerSmathK Offline
      KillerSmath
      wrote on last edited by
      #2

      @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.

      @Computer Science Student - Brazil
      Web Developer and Researcher
      “Sometimes it’s the people no one imagines anything of who do the things that no one can imagine.” - Alan Turing

      1 Reply Last reply
      3

      • Login

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