Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QNetworkConfigurationManager::allConfigurations() doesn't list WLAN

Running under Windows 10, tested with two different Systems:

When i run QNetworkConfigurationManager::allConfigurations() I don't get any WLAN configuration, even if I'm connected actively to a Wifi Network.

Header:

public:
  NetworkManager(QObject* parent = 0);

private slots:
  void onNetworkConfigUpdate();

private:
  QNetworkConfiguration cfg;
  QList<QNetworkConfiguration> netcfgList;
  QNetworkConfigurationManager ncm;

.cpp

NetworkManager::NetworkManager(QObject* parent) : QObject(parent) {
    ncm.updateConfigurations();
    connect(&ncm, SIGNAL(updateCompleted()), this,  SLOT(onNetworkConfigUpdate()));
}

void NetworkManager::onNetworkConfigUpdate() {
netcfgList = ncm.allConfigurations();
for (auto& x : netcfgList) {
    if (x.bearerType() == QNetworkConfiguration::BearerWLAN) {
        qDebug() << "Wifi found: " << x.name();
    } else {
        qDebug() << "Something else: " << x.bearerType() << " - name: " << x.name();
    }
  }
}

Output:

Something else: 0 - name: "Teredo Tunneling Pseudo-Interface"

Something else: 1 - name: "Ethernet"

Something else: 1 - name: "VirtualBox Host-Only Network"

I'm running on Windows 10; Qt 5.9.4 with MSVC2015

I checked with an Intel Wireless Card and an external USB Wifi-Stick. Why is it not showing any WLAN?

like image 589
gekko42 Avatar asked Feb 13 '18 13:02

gekko42


1 Answers

I had the same problem. To me was caused by a missing bearer plugin DLL.

To sort this out, I had to copy the QT "plugins/bearer" folder (containing qgenericbearer.dll and qnativewifibearer.dll) in my application root folder.

Like this:

  • ApplicationFolder/
    • Application.exe
    • ...
    • Qt5Network.dll
    • bearer/
      • qgenericbearer.dll
      • qnativewifibearer.dll
like image 128
Sneezeface Avatar answered Nov 15 '22 04:11

Sneezeface