Qt check Internet connection*
-
wrote on 4 Nov 2010, 14:40 last edited by
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
-
wrote on 4 Nov 2010, 14:45 last edited by
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
-
wrote on 4 Nov 2010, 14:51 last edited by
yes i know
but I still need to bring up the connection dialog if there is no connection active -
wrote on 4 Nov 2010, 15:08 last edited by
unfortunately i cant tell you how you can call the dialog. I never coded something for a mobile project
-
wrote on 4 Nov 2010, 15:12 last edited by
Check the qt mobility examples, e.g. the flickrdemo
-
wrote on 4 Nov 2010, 15:20 last edited by
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 -
wrote on 5 Nov 2010, 17:46 last edited by
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.
-
wrote on 8 Jun 2012, 13:04 last edited by
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. -
wrote on 8 Jun 2012, 15:13 last edited by
File a bug report then, please.
-
wrote on 13 Jun 2012, 14:27 last edited by
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.