贡献自己写的,在linux,arm上的屏幕搜索wifi并连接(qt,多选择,wifi按信号排列)
先上代码!!
#include "widget.h"
#include "ui_widget.h"
#include <QVBoxLayout>
#include <QMessageBox>
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
int i =0;
int j =0;
int t =0;
QVBoxLayout *groupBoxLayout;
groupBoxLayout = new QVBoxLayout;
system("iwlist wlan1 scan >./temp ");
system("grep -E \"SSID|Quality\" temp >./grepTemp");
system("grep -v \"x00\" grepTemp >./temp");
QString fileName;
fileName = "/home/c/qt/WifiSelect/temp";
QFile file(fileName);
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
{
qDebug()<<"!";
return;
}
QTextStream in(&file);
QString line = in.readLine();
while (i<20)
{
line = in.readLine();
for(t=27;t<line.size()-1;t++) //take off other words
{
wifiName[i] +=line[t];
}
line = in.readLine();
for(t=28;t<30;t++) //take off other words
{
temp[i] +=line[t];
}
i++;
}
for(i=0;i<20;i++)
{
qDebug()<<"temp"<<temp[i];
qDebug()<<"name"<<wifiName[i];
}
for(i=0;i<19;i++)
{
for(j=1;j<20;j++)
{
if(temp[i]<temp[j])
{
transfer = temp[i];
temp[i] = temp[j];
temp[j] = transfer;
transfer =wifiName[i];
wifiName[i] = wifiName[j];
wifiName[j] = transfer;
}
}
}
i =0;
j =0;
int k=0;
while(i<10)
{
if(wifiName[j] == '\0')
{
// break;
k++;
if(k ==10)
{
qDebug()<<"false";
QMessageBox messageBox;
messageBox.setText(tr("无法搜索WLAN信号"));
message