#includeint main() { QHostAddress address("192.168.1.1"); uint32_t ip = address.toIPv4Address(); qDebug() << "IP address: " << address.toString() << " in integer format: " << ip; }
#includeThis example initializes a QHostAddress object with the localhost IP address and then calls the toIPv4Address() method to convert it to an unsigned 32-bit integer. The IP address and its integer representation are then printed to the console using qDebug(). Package library: Qt Network module in the Qt library.int main() { QHostAddress address(QHostAddress::LocalHost); uint32_t ip = address.toIPv4Address(); qDebug() << "IP address: " << address.toString() << " in integer format: " << ip; }