Results 1 to 7 of 7

Thread: Application won't quit until event loop quits

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2009
    Location
    The Netherlands and Spain
    Posts
    150
    Thanks
    6
    Thanked 18 Times in 18 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Application won't quit until event loop quits

    You don't have to start your own eventloop.
    Just connect to the loadFinished signal and do all your testing in that slot.

  2. #2
    Join Date
    Feb 2010
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Application won't quit until event loop quits

    Yes, but I need to wait for the page to finish loading so it would be like a blocking function. Right now I have some functions and when I load a web page I need to wait until the program finishes loading the page before I continue to the next step. I need to wait for new pages many times, so splitting my one function that loads many pages into many functions connected to each other is infeasible.

    Qt Code:
    1. foo () {
    2. load page
    3. wait for page to load
    4. do stuff to the page
    5. load page
    6. wait for page to oad
    7. do stuff
    8. ...
    9. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Feb 2010
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Application won't quit until event loop quits

    I still do not have a fix, can someone provide a solution?

  4. #4
    Join Date
    Feb 2010
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Application won't quit until event loop quits

    Anyone? Even a small hint?

  5. #5
    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: Application won't quit until event loop quits

    Some untested thoughts...

    You could establish a QSemaphore as a member variable, with an initial count of 0. Create a slot to receive loadFinished() signals and execute QSemaphore::release() to release 1 resource (nothing else required). Between each request and the test (where you are looping now) use QSemaphore::acquire(1), which will block until a loadFinished() is received and a resource is released. You need to ensure a time out will apply if the page never returns.

    You could, alternatively, busy wait on a boolean flag set by the loadFinished() receiving slot. Something like
    Qt Code:
    1. m_finishedFlag = false;
    2. ... issue request
    3. while (!m_finishedFlag)
    4. qApp->processEvents();
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Why my application quit?
    By yxtx1984 in forum Newbie
    Replies: 1
    Last Post: 7th February 2010, 05:46
  2. Replies: 10
    Last Post: 15th January 2010, 14:35
  3. Qt 4 quits application [solved]
    By osiris81 in forum Qt Programming
    Replies: 1
    Last Post: 3rd December 2008, 14:07
  4. Replies: 0
    Last Post: 23rd October 2008, 12:43
  5. Qt plug-in for GLib event loop based application
    By profoX in forum Qt Programming
    Replies: 1
    Last Post: 14th June 2008, 14:27

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.