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
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] QTimer in mainwindow class

Scheduled Pinned Locked Moved General and Desktop
qtimer
2 Posts 1 Posters 1.6k 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.
  • DuncanD Offline
    DuncanD Offline
    Duncan
    wrote on 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
    • DuncanD Offline
      DuncanD Offline
      Duncan
      wrote on last edited by
      #2

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

      :)

      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