Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-56760

QNetworkSettings API is unusable from C++

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P1: Critical
    • Resolution: Done
    • Affects Version/s: 5.7.0
    • Fix Version/s: None
    • Component/s: Device Creation
    • Labels:
      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.

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            teemu.holappa Teemu Holappa
            Reporter:
            rakeller Rainer Keller
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes