How to connect to a wifi with qt

3

Good afternoon, can someone help me? I need to make an application in c ++ using QT. It has to look for wireless connections and connect to a specific one. I hope you can help me

    
asked by Raudel 26.10.2016 в 18:10
source

1 answer

5

If you use version 5.6 (I can not tell if previous versions have it), you have at your disposal the B2QtWifi library that allows you to access WIFI features of the device.

So, for example, you could list the available wifis in a QListView with a code such that (taken from the Qt website):

auto m_wifiManager = QWifiManager::instance();
listView->setModel(m_wifiManager->networks());

Connect to the selected Wi-Fi:

QModelIndex index = m_listView->currentIndex();
QWifiConfiguration config;
if (index.isValid()) {
    QString ssid = qvariant_cast<QString>(index.data(QWifiManager::SSID));
    config.setSsid(ssid);
    config.setPassphrase(/* clave para la wifi */);
    m_wifiManager->connect(&config);
}

For more information, I recommend consulting the documentation in its original source:

Greetings.

    
answered by 26.10.2016 в 22:49