Get local IP address in Qt

前端 未结 6 1254
借酒劲吻你
借酒劲吻你 2020-12-05 17:26

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

6条回答
  •  青春惊慌失措
    2020-12-05 18:05

    QNetworkInterface::allAddresses() will give you the network addresses. You can then filter the results to IPv4 addresses that are not loopback addresses:

    QList list = QNetworkInterface::allAddresses();
    
     for(int nIter=0; nIter

提交回复
热议问题