QUrl url("http://example.com:8080/path/to/resource"); QString authority = url.authority(); // "example.com:8080" QString hostname = url.host(); // "example.com" int port = url.port(); // 8080
QUrl url("http://example.com/path/to/resource"); url.setAuthority("new.example.com:8080"); QString newUrl = url.toString(); // "http://new.example.com:8080/path/to/resource"The QUrl class is a part of the Qt Core module.