KURL url("http://www.example.com"); url.setPort(8080);
KURL url("http://www.example.com:8080"); QString portStr = "9090"; url.setPort(portStr.toUInt());In the first example, the port number 8080 is set for the URL "http://www.example.com". In the second example, the port number is set from a string input, where the value of portStr is first converted to an unsigned integer using the toUInt method. Package/Library: Qt library.