Create network Session without user interaction
Article Metadata
Sometime we have required to configure network bearer according to use. We can manage the network configurations by use of QNetworkConfigurationManager. Here is a simple code to do this.
QNetworkConfigurationManager conf;
const bool isAccessPoint = (conf.capabilities() & QNetworkConfigurationManager::BearerManagement );
QNetworkConfiguration netConf = conf.defaultConfiguration();
if(netConf.isValid() || !isAccessPoint)
return;
switch (netconf.type()) {
case QNetworkConfiguration::InternetAccessPoint:
// System start the IAP immediately
break;
case QNetworkConfiguration::ServiceNetwork:
// System determines the best IAP available and starts it immediately
break;
case QNetworkConfiguration::UserChoice:
//the AP is resolved by asking the user
break;
case QNetworkConfiguration::Invalid:
//Invalid IAP
break;
}
QNetworkSession* sess = new QNetworkSession (netConf);
sess->open();

