I am using Qt5 on Windows 7.
In my application (TCP server), I am currently using some methods from QTcpSocket class:
- QAbstractSocket::peerAddress(
If you can run code on remote peer, MAC address can be reported with hardwareAddress() call of the interface.
For example , to report MAC address of WiFi interface, and all IPv4 addresses on that intrface:
for(const QNetworkInterface& iface: QNetworkInterface::allInterfaces()){
if (iface.type() == QNetworkInterface::Wifi){
qDebug() << "MAC:" << iface.hardwareAddress();
for (const QHostAddress& addr : iface.allAddresses()){
if (addr.protocol() == QAbstractSocket::IPv4Protocol)
qDebug() << "IPv4 Addr: " << addr;
}
}
}