Qt下如何獲得本地網絡卡IP

2021-06-12 01:33:33 字數 431 閱讀 4247

#include #include #include #include getipv4::getipv4()

{ qtextcodec::setcodecforcstrings(qtextcodec::codecforname("utf-8"));

qlistvaddresslist = qnetworkinte***ce::alladdresses();

for(int i=0;i

以上是**:

以下是執行結果:

qhostaddress( "127.0.0.1" ) 

qhostaddress( "0:0:0:0:0:0:0:1" ) 

qhostaddress( "192.168.0.105" ) 

qhostaddress( "fe80:0:0:0:20c:29ff:fe1b:6f25" ) 

設定本地網絡卡IP位址的批處理

這是乙個很好用的批處理命令集,可以設定自動獲得,可以手動設定,可以預先設定好後儲存。方案1 set a num 1 set project num 測試網路 set nname lan num 本地連線 set addr lan num 192.168.0.142 set mask lan num ...

qt獲得本地IP的方法

環境 ubuntu10.04 qt4.7.0 linux獲得本地ip的方法,我嘗試了兩種 1.用qhostinfo類解析 qhostinfo類可以解析網域名稱,理論上也可以解析本地ip,可是經過嘗試,我發現解析出來的ip是127.0.0.1是本地回環位址,不符合我的需求。獲取本地ip qhostin...

雙網絡卡或多網絡卡情況下獲得所有的IP位址

在編寫基於sock的網路程式時,有時需列舉系統中繫結的所有ip位址,在一般控制項無法解決些問題的情況下,可使用如下方法一試 include stdafx.h include include include include void main gethostname myname,80 取得主機名 t...