PDA

View Full Version : Detecting network type is 3G or Wifi



lyhoanghai
25th August 2010, 15:00
Hello,

I would like my application to behave differently for Wifi and 3G network.
The problem is that my application has to detect which network that QNetworkAccessManager is using.

For Qt 4.7, QNetworkAccessManager has a method called configuration() which returned the configuration used for creating connection.
If I want to do the same thing for Qt4.6, how do I do that? (4.6 does not have configuration method).

Any idea aboyt this?

Thank

Hai

tbscope
26th August 2010, 05:55
If Qt-4.7 already has this:
http://qt.gitorious.org/qt

You can look at the code of QNetworkAccessManager.

lyhoanghai
26th August 2010, 09:01
Thanks for your link.
A quick look to QNetworkAccessManager.createRequest() shows that


if (!d->networkSession && (d->initializeSession || !d->networkConfiguration.isEmpty())) {

966

QNetworkConfigurationManager manager;

967

if (!d->networkConfiguration.isEmpty()) {

968

d->createSession(manager.configurationFromIdentifier( d->networkConfiguration));

969

} else {

970

if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequir ed)

971

d->createSession(manager.defaultConfiguration());

972

else

973

d->initializeSession = false;

974

}

975

}


Thus, QNetworkAccessManager use NetworkConfigurationManager.defaultConfiguration() .