I have some simple code to read a web page. You have seen the code before, it is very simple:
QNetworkRequest request;
hostUrl.setUrl("http://qt.nokia.com");
request.setUrl(hostUrl);
QNetworkReply* reply = networkAccessManager->get(request);
QNetworkRequest request;
QUrl hostUrl;
hostUrl.setUrl("http://qt.nokia.com");
request.setUrl(hostUrl);
QNetworkReply* reply = networkAccessManager->get(request);
To copy to clipboard, switch view to plain text mode
Next, I connect more connections than seems reasonable. My question is, how should I do this in a GUI? My initial solution was to run this code in a slot that was called from a menu item. Of course, I have no response unless i start an event loop:
loop.exec();
QEventLoop loop;
loop.exec();
To copy to clipboard, switch view to plain text mode
I had expected that this would use the GUI's event loop (a GUI always has an event loop, right?) You know, started this way
MainWindow w;
w.show();
return a.exec();
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
To copy to clipboard, switch view to plain text mode
That said, I find it disturbing that I started an event loop in a handler for a menu command.
Bookmarks