Details
-
Bug
-
Resolution: Done
-
P1: Critical
-
None
-
5.7.0
-
None
Description
I am trying to create a Wi-Fi connection from C++.
(pseudocode)
slot void setupWifi(){ manager->getService("networkName", QNetworkSettingsType::Wifi); if (!mService) { errorMessage(); } else { doSetup(); } } main() { manager = new QNetworkSettingsManager(); connect(manager, servicesChanged, this, setupWifi); }
When the signal "servicesChanged" is emitted all the network names are empty and each network type is 'unknown'. In this case "getService" will never return anything. The names and types of the networks are received asynchronously via DBus. But after all information retrieval is done the end user code is not notified again.
You have to find a solution where you can notify the end user code when it makes sense to use the "getService" to return some actual service.
The same applies to the network type. When asking "getService" for a Wifi type network the first time all networks are in "unknown" state and will not return a value. The users have to wait until enumeration has completed.
I made a quick and dirty patch https://codereview.qt-project.org/#/c/175046/ which emits the signal 'servicesChanged' on every name and type change. This allows customers to retry getting the network service.