Not saying this is right, but it seems to work for some simple cases:
Code:
// Note: Should be calling updateConfigurations here. See QNetworkConfigurationManager::allConfigurations writeup.
QNetworkConfiguration cfg = manager.defaultConfiguration();
if (!cfg.isValid() || (!canStartIAP && cfg.state() != QNetworkConfiguration::Active)) {
QMessageBox::information(this, tr("TestMobility"), tr("Available Access Points not found."));
return;
}
if (cfg.type() == QNetworkConfiguration::UserChoice) {
QNetworkConfiguration::StateFlags flags = QNetworkConfiguration::Discovered | QNetworkConfiguration::Active;
QList<QNetworkConfiguration> allCfg = manager.allConfigurations(flags);
// Just take the first one -- need a better algorithm to pick one
if (allCfg.count() > 0) {
cfg = allCfg.at(0);
}
}