How can I connect to wifi using QT
-
wrote on 7 Jul 2021, 12:24 last edited by
Hello I'm trying to connect to wifi using following code.
QNetworkConfiguration cfg;
QNetworkConfigurationManager ncm;
auto nc = ncm.allConfigurations();for (auto &x : nc)
{
if (x.bearerType() == QNetworkConfiguration::BearerWLAN)
{
qDebug() << x.name();
if (x.name() == "YouDesiredNetwork")
cfg = x;
}
}
auto session = new QNetworkSession(cfg, this);
session->open();but is not connecting to network
also in ubuntu it gives me list of wifi network but when I run this in windows it is showing me below output(I have 5 available networks)
output: -
"Wi-Fi"
"Local Area Connection* 9" -
wrote on 8 Jul 2021, 04:11 last edited by
The simplest solution is often the correct one.
Are you sure the WIFI profiles have the correct key stored in them?
What does the error code state() of session indicate? -
Hello I'm trying to connect to wifi using following code.
QNetworkConfiguration cfg;
QNetworkConfigurationManager ncm;
auto nc = ncm.allConfigurations();for (auto &x : nc)
{
if (x.bearerType() == QNetworkConfiguration::BearerWLAN)
{
qDebug() << x.name();
if (x.name() == "YouDesiredNetwork")
cfg = x;
}
}
auto session = new QNetworkSession(cfg, this);
session->open();but is not connecting to network
also in ubuntu it gives me list of wifi network but when I run this in windows it is showing me below output(I have 5 available networks)
output: -
"Wi-Fi"
"Local Area Connection* 9"@Sanskar What about connecting slots to https://doc.qt.io/qt-5/qnetworksession.html#error-1 and https://doc.qt.io/qt-5/qnetworksession.html#stateChanged and checking https://doc.qt.io/qt-5/qnetworksession.html#errorString and state there?
1/3