PDA

View Full Version : Pre app.exec() behavior question



sgmurphy19
15th September 2008, 21:29
In my main, before I call app.exec() I try to automate a call to http. If in the call, I add a QMessageBox:: then it executes properly, but if I don't then it doesn't follow through.

example:
int main(int argc, char *argv[])
{
MainWindow win();
win.checksomething();
app.exec();
}

void MainWindow::checksomething()
{
progressDialog->setWindowTitle(tr("Checking Something"));
progressDialog->show();
uhttp->setHost("localhost");
httpGetRequest = true;
downloadGetRequest = true;
QString xmlFile = "XML.xml";
httpGetId = uhttp->get(xmlFile);
progressDialog->setLabelText(tr("Reading %1.").arg(xmlFile));
QMessageBox::information(NULL, "update check", "Checking for Updates");
//If I don't have the QMessageBox above, then this never gets downloaded
}

Any ideas why this happens?

Thanks,
Sean

jacek
15th September 2008, 21:46
QHttp needs a running event loop.

sgmurphy19
15th September 2008, 21:48
And calling QMessageBox starts that?

jacek
15th September 2008, 22:02
And calling QMessageBox starts that?
Yes, modal dialogs start a local event loop.