QT 获取 本机IP地址 MAC地址


    QString str1;
    QHostInfo info = QHostInfo::fromName(QHostInfo::localHostName());
    QHostAddress address = info.addresses().first();      //第一个IP地址;
    str1 = address.toString();



 
 
    QString str2;
    QList<QNetworkInterface> list = QNetworkInterface::allInterfaces();
    str2 = list.at(1).hardwareAddress();                  //MAC地址;


你可能感兴趣的:(list,qt)