示例:使用QT来获取Windows电脑WIFI列表中所有WIFI的名称,实际是执行CMD命令来完成(netsh wlan show networks)
// 获取WIFI列表 QProcess process; process.start("netsh wlan show networks"); process.waitForStarted(); process.waitForFinished(); QString cmd_res_text = QString::fromLocal8Bit(process.readAllStandardOutput()); //qDebug() << cmd_res_text; // 提取有效数据 QStringList cmd_res_list_old = cmd_res_text.split("\r\n"); QStringList cmd_res_list; for (int i = 0; i < cmd_res_list_old.count(); i++) { if (cmd_res_list_old.at(i).contains("SSID")) { cmd_res_list.push_back(cmd_res_list_old.at(i)); } } // 提取WIFI名称 QStringList wifi_name_list; for each (QString i in cmd_res_list) { QStringList temp_list = i.split(" "); QString temp_wifi_name = temp_list.last(); if (!temp_wifi_name.isEmpty()) { wifi_name_list.push_back(temp_wifi_name); } } // 添加到下拉框 for each (QString name in wifi_name_list) { ui.comboBox->addItem(name); }
标签:wlan,Qt,show,process,WIFI,列表,获取 From: https://www.cnblogs.com/shiyixirui/p/17965357