QHostAddress address("192.168.0.1"); QString addressString = address.toString();
QHostAddress address(QHostAddress::LocalHost); QString addressString = address.toString();
QHostAddress address; address.setAddress("fd12:3456:7890:1::1"); QString addressString = address.toString();In this example, a QHostAddress object is created with an IPv6 address. The setAdress function is used to set the IP address, and the toString function is then called to convert the IP address to a string representation. The QHostAddress class is a part of the Qt Network module, which is included in the package library of Qt.