My program uses QtNetwork to download stuff from internet.
in int main() I call
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QmlApplicationViewer viewer;
QNetworkConfigurationManager manager;
QNetworkConfiguration cfg = manager.defaultConfiguration();
QNetworkSession* session = new QNetworkSession(cfg);
session->setSessionProperty("ConnectInBackground", true);
session->open();
/*some registering types*/
viewer.setOrientation(QmlApplicationViewer::ScreenOrientationAuto);
viewer.setMainQmlFile(QLatin1String("qml/maelyrica/main.qml"));
viewer.showFullScreen();
return app.exec();
}
Then, in one member function, a lot of encapsulation, a lot of calling other member functions which call other member functions, such code is used:
QNetworkReply::NetworkError lyricsDownloader::download(const QString& a, const QString& t)
{
QNetworkAccessManager nam;
QNetworkReply * reply;
QUrl url = toProviderCode(a, t);
forever
{
reply = nam.get(QNetworkRequest(url));
QEventLoop downloadLoop;
connect(reply, SIGNAL(finished()), &downloadLoop, SLOT(quit()));
downloadLoop.exec();
url = reply->attribute(QNetworkRequest::RedirectionTargetAttribute).toUrl();
if (url.isEmpty()) break; // break when no redirect, when redirect do it again with new url
}
lyrics_qstr = reply->readAll();
//qDebug() << lyrics_qstr;
return reply->error();
}
This should show an internet popup on mobile devices such as Nokia N9 or Nokia N900, i.e. user has to choose the internet connection unless he’s already connected. But it isn’t shown.
What am I doing wrong?
Thanks in advance
You have set “ConnectInBackground” to true.
“Setting this property to true before calling open() implies that the connection attempt is made but if no connection can be established, the user is not connsulted and asked to select a suitable connection. This property is not set by default and support for it depends on the platform.”