Is there a cross-platform way to get the local IP address (i.e. something that looks like 192.168.1.49
) of the computer using Qt?
I want to make an FTP server for a Symbian phone and I want to show the IP address the FTP client should connect to.
Use QNetworkInterface::allAddresses()
const QHostAddress &localhost = QHostAddress(QHostAddress::LocalHost);
for (const QHostAddress &address: QNetworkInterface::allAddresses()) {
if (address.protocol() == QAbstractSocket::IPv4Protocol && address != localhost)
qDebug() << address.toString();
}