你如何连接到QT或Windows API中的无线WIFI网络?(how do you connect to a Wireless WIFI Network in QT or windows API? [closed])
有没有用于检测无线网络的API? ,或任何QT类来检测无线网络并连接到它们。 QNetworkInterface是最接近的类,但它不支持它。
is there any APIs for detecting wireless networks? , or any QT class for detecting wireless networks and connecting to them . QNetworkInterface is the closest class but it does not support it .
最满意答案
你可以使用QNetworkConfigurationManager和QNetworkSession
QNetworkConfiguration cfg; QNetworkConfigurationManager ncm; auto nc = ncm.allConfigurations(); for (auto &x : nc) { if (x.bearerType() == QNetworkConfiguration::BearerWLAN) { if (x.name() == "YouDesiredNetwork") cfg = x; } } auto session = new QNetworkSession(cfg, this); session->open();它首先用你想要的名字搜索网络,然后尝试连接到它。
You can use QNetworkConfigurationManager and QNetworkSession
QNetworkConfiguration cfg; QNetworkConfigurationManager ncm; auto nc = ncm.allConfigurations(); for (auto &x : nc) { if (x.bearerType() == QNetworkConfiguration::BearerWLAN) { if (x.name() == "YouDesiredNetwork") cfg = x; } } auto session = new QNetworkSession(cfg, this); session->open();It first searches for the network with you desired name and then tries to connect to it.
更多推荐
发布评论