Qt check Internet connection*
-
Hi,
I'm working on a project for Maemo and Symbian on C++/Qt
Can someone tell me how can I just check if there is a active Internet connection in Qt? If active start the app, if not display the choose connection dilaog.
I see I have to do this with Bearer Managment which is implemented in Qt 4.7, but I'm a little lost in the documentation
-
you could also do it with QNetworkAccessManager. Just make a Http request on a very active site (e.g. www.google.com) when the reply is finished, it has an error code. When this ErrorCode == QNetworkReply::NoError you can assume an internet connection.
I know this is not the best solution, but a simple one
-
thank for advice
but that example won't do
bearer magement has been moved from mobility to qt since 4.7
not all the things are the same
i found some documentation on "http://doc.qt.nokia.com/4.7-snapshot/bearer-management.html":http://doc.qt.nokia.com/4.7-snapshot/bearer-management.htmlbut as i said, i'm a little lost in the documentation
i don't get how to accomplish just to make a check, and call the dialog if needed -
Does "QNetworkConfigurationManager::isOnline()":http://doc.qt.nokia.com/4.7-snapshot/qnetworkconfigurationmanager.html#isOnline sound like what you need?
The "bearer monitor example":http://doc.qt.nokia.com/4.7-snapshot/network-bearermonitor.html might also be of interest.
-
On Symbian QNetworkConfigurationManager::isOnline() returns false even when WiFi is On and connected to internet.
I don't have any simple method to check network connectivity with Qt on Symbian. -
Use "QNetworkSession":http://qt-project.org/doc/qt-4.8/qnetworksession.html
@
QNetworkSession *session = new QNetworkSession(QNetworkConfigurationManager::defaultConfiguration());
session->open();
@Opening session should handle displaying connection dialog if needed.