Results 1 to 2 of 2

Thread: Is it possible to cancel the call to QTimer::singleShot?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2009
    Location
    US, Midwest
    Posts
    215
    Thanks
    62
    Thanked 4 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Is it possible to cancel the call to QTimer::singleShot?

    Suppose, after I made a call to QTimer::singleShort, application logic requires cancellation of this operation. I don' see a way to cancel it, is it possible to do?

    Thanks!

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Is it possible to cancel the call to QTimer::singleShot?

    No, you have no access to the actual timer created by the static call.

    You can create a single shot (zero time) timer explicitly and you should be able to stop() or delete that object before it fires.

    Alternatively, track whether a single-shot timer is needed separately in a bool variable. Then, just before returning control to the event loop, create the single shot timer if required.

  3. The following user says thank you to ChrisW67 for this useful post:

    TorAn (3rd April 2016)

Similar Threads

  1. QTimer::singleShot(0, ... confusion
    By bjoern83 in forum Qt Programming
    Replies: 5
    Last Post: 9th October 2022, 10:30
  2. Replies: 3
    Last Post: 31st January 2010, 16:56
  3. Replies: 8
    Last Post: 10th December 2009, 10:06
  4. multiple QTimer::singleShot() calls?
    By mattc in forum Qt Programming
    Replies: 1
    Last Post: 27th July 2009, 19:22
  5. Replies: 1
    Last Post: 6th April 2006, 12:24

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.