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. [SOLVED] QTimer in mainwindow class

[SOLVED] QTimer in mainwindow class

Scheduled Pinned Locked Moved General and Desktop
qtimer
2 Posts 1 Posters 1.6k 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.
  • D Offline
    D Offline
    Duncan
    wrote on 20 Jun 2015, 03:11 last edited by Duncan
    #1

    Hello!

    I'm trying to call a function in my main window class every 5 seconds, what is the best way to do this?

    I tried using QTimer, but could not get it to work. Below is what I have tried so far:

    Mainwindow.h File:

    private: QTimer *primeTime;

    Mainwindow.cpp File:

       primeTime = new QTimer(this);
          connect(primeTime, SIGNAL(timeout()), this, SLOT(timeCheck()));
          primeTime->start(1000); 
    

    Thanks for your time,

    Duncan

    1 Reply Last reply
    0
    • D Offline
      D Offline
      Duncan
      wrote on 20 Jun 2015, 05:58 last edited by
      #2

      Forgot to add the #include <QTimer> in the mainwindow.h file

      :)

      1 Reply Last reply
      0

      1/2

      20 Jun 2015, 03:11

      • Login

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