You don't have to start your own eventloop.
Just connect to the loadFinished signal and do all your testing in that slot.
You don't have to start your own eventloop.
Just connect to the loadFinished signal and do all your testing in that slot.
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:
foo () { load page wait for page to load do stuff to the page load page wait for page to oad do stuff ... }To copy to clipboard, switch view to plain text mode
I still do not have a fix, can someone provide a solution?
Anyone? Even a small hint?
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 likeQt Code:
m_finishedFlag = false; ... issue request while (!m_finishedFlag) qApp->processEvents();To copy to clipboard, switch view to plain text mode
Bookmarks