Results 1 to 2 of 2

Thread: Pause / Wait / Sleep for the application herself

  1. #1
    Join Date
    Feb 2007
    Posts
    158
    Thanks
    25
    Qt products
    Qt4
    Platforms
    Windows

    Default Pause / Wait / Sleep for the application herself

    Hi,

    I've finished the developement of an application, and I would like to add a small pause of 10 seconds in a function...

    I've seen the Pause/Wait/Sleep functions, but the don't apply to an application. We can use them only in particular cases, like threads. I don't want to rewrite my application with threads...

    But I've also heard that a QApplication is a thread. So, is there anything to create a small pause in my application ? Perhaps should I call a system function like system("pause") ?

    Thanks for your hints

  2. #2
    Join Date
    Oct 2006
    Posts
    279
    Thanks
    6
    Thanked 40 Times in 39 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Pause / Wait / Sleep for the application herself

    You can call sleep() in any function but if it is in the main (GUI) thread your application will freeze and become unresponsive. You could try:
    Qt Code:
    1. while(timeIsntUp)
    2. QCoreApplication::processEvents();
    To copy to clipboard, switch view to plain text mode 
    You will probably have to block the user from repeating the action which lead to the function being called. I.e. graying out a button or something similar.

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
  •  
Qt is a trademark of The Qt Company.