PDA

View Full Version : How to use QEventLoop?



MorrisLiang
13th May 2010, 03:59
The app I'm creating is relative to the network.I want it to check if the username/password is valid when it starts.And while validating,nothing can the user do.I also want to make the UI responsible.So I think of QEventLoop(I guess that's what I need,right?)

Here,I use validate() to check the info.


bool MyApp::validate()
{
QString requestURL = "http://xxxxxx.com/check?username=aaa&password=bbb";
QNetworkReply* reply= manager.get(QNetworkRequest(requestURL));
....
}


HOW do I use QEventLoop inside the validate(),so that I can return ture/false,when the server tells me whether the info is correct.

JD2000
13th May 2010, 13:43
I'm not sure I understand your question, wont some sort of modal login (dialog) box achieve this?

You may want to have a look at Wysota's login box http://www.wysota.eu.org/wwwidgets/

wysota
13th May 2010, 14:59
You don't need QEventLoop. Just set the enabled property of your GUI window to false while sending the request and enable it back again in the slot connected to the signal emitted when the response arrives.

MorrisLiang
13th May 2010, 16:23
Thanks,both of you enlighten me~I was a little stubborn at this point.ha:p