你如何连接到一个无线WIFI网络在QT或Windows API? [英] how do you connect to a Wireless WIFI Network in QT or windows API?

查看:3717
本文介绍了你如何连接到一个无线WIFI网络在QT或Windows API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有用于检测无线网络的任何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 .

推荐答案

您可以使用<一个href=\"http://harmattan-dev.nokia.com/docs/library/html/qt4/qnetworkconfigurationmanager.html\"><$c$c>QNetworkConfigurationManager和<一个href=\"http://harmattan-dev.nokia.com/docs/library/html/qt4/qnetworksession.html\"><$c$c>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.

这篇关于你如何连接到一个无线WIFI网络在QT或Windows API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆