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 start a QEventLoop and triggers a function every 5 seconds.
Qt 6.11 is out! See what's new in the release blog

How to start a QEventLoop and triggers a function every 5 seconds.

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 1.2k 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
    Aj_Phantom
    wrote on last edited by
    #1

    I have an application that would start a service when a button is clicked. I have a function that would check if the service is started more like an assertion. I have the idea on what needs to be done but not sure how I am supposed to implement it.

    1. I should be able to call the function that checks for the status of the service every 5 seconds only if the status is false(inactive).
    2. The limit should be 30 seconds. Which means the function that checks for service status is called 6 times at max.
    3. If the limit is reached exit the event loop. If the status is true(active) when checked after 10 seconds, then exit the loop as well.

    If I could get a clear implementation detail on how to proceed with this situation it would be a great help.

    Thanks and regards

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Don't use an extra eventloop but a QTimer.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      A 1 Reply Last reply
      3
      • Christian EhrlicherC Christian Ehrlicher

        Don't use an extra eventloop but a QTimer.

        A Offline
        A Offline
        Aj_Phantom
        wrote on last edited by
        #3

        @Christian-Ehrlicher
        I am kind of newbie to Qt so if you could be little more specific by providing an example that would highly appreciable.

        1 Reply Last reply
        0
        • Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #4

          The detailed description should help here.
          Create timer, connect timeout to the your custom slot, do your work and checks in there.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          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