Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to trigger a slot after an interval
Qt 6.12 LTS is out! See what's new in the release blog

How to trigger a slot after an interval

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

    I wan to avoid the user to change the selection every time when they click a button.

    Is there a way to make a slot to call after an interval like 2 secs? If the user has a new click action, then It can drop the previous call and make a new call from the slot? If possible, giving me an example would be better. Thank you very much.

    JonBJ 1 Reply Last reply
    0
    • C clementNg

      I wan to avoid the user to change the selection every time when they click a button.

      Is there a way to make a slot to call after an interval like 2 secs? If the user has a new click action, then It can drop the previous call and make a new call from the slot? If possible, giving me an example would be better. Thank you very much.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @clementNg said in How to trigger a slot after an interval:

      Is there a way to make a slot to call after an interval like 2 secs?

      In principle, yes, you can use a QTimer for that. However, it does not sound like that is what you want. Your slot belongs on the clicked signal, not on a timer signal. Instead it is your job to save the time when the slot is clicked, and the next time it is clicked ignore it if it is within 2 seconds of the previous click. Or whatever it is you are saying you want to do/not do, using that approach.

      Or, perhaps you are saying you are wanting to: on click, don't act on it immediately, instead start a 2-second QTimer, and act on that when it expires, if user has not clicked something else.

      I can't tell exactly what you want from your description.

      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
      • Unsolved