需要修改wifi的配置文件,删除再穿件一个总感觉不太好,找到一篇可以修改文件的博客。
基本流程:
https://blog.csdn.net/caoshangpa/article/details/51775147
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50QString strAll; QStringList strList; QFile readFile("test.txt"); if(readFile.open((QIODevice::ReadOnly|QIODevice::Text))) { QTextStream stream(&readFile); strAll=stream.readAll(); } readFile.close(); QFile writeFile("test.txt"); if(writeFile.open(QIODevice::WriteOnly|QIODevice::Text)) { QTextStream stream(&writeFile); strList=strAll.split("n"); for(int i=0;i<strList.count();i++) { if(i==strList.count()-1) { //最后一行不需要换行 stream<<strList.at(i); } else { stream<<strList.at(i)<<'n'; } if(strList.at(i).contains("iface eth0 inet static")) { QString tempStr=strList.at(i+1); tempStr.replace(0,tempStr.length()," address 192.168.1.111"); stream<<tempStr<<'n'; tempStr=strList.at(i+2); tempStr.replace(0,tempStr.length()," netmask 255.255.255.0"); stream<<tempStr<<'n'; tempStr=strList.at(i+3); tempStr.replace(0,tempStr.length()," network 192.168.1.0"); stream<<tempStr<<'n'; tempStr=strList.at(i+4); tempStr.replace(0,tempStr.length()," geteway 192.168.1.1"); stream<<tempStr<<'n'; i+=4; } } } writeFile.close();
最后
以上就是兴奋小蝴蝶最近收集整理的关于QT wifi连接的全部内容,更多相关QT内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复