#includeQString urlStr = "https://www.example.com/path/to/some/page.html?query=value#fragment"; KUrl url(urlStr); QString scheme = url.scheme(); // "https" QString host = url.host(); // "www.example.com" int port = url.port(); // 443 (default for https) QString path = url.path(); // "/path/to/some/page.html" QString fileName = url.fileName(); // "page.html" QString query = url.query(); // "query=value" QString fragment = url.fragment(); // "fragment"
#includeThis example demonstrates how KURL can be used to build a complete URL by setting its individual components and then constructing the final URL. Overall, KURL is a valuable C++ library for working with URLs as it provides a wide range of functionalities for parsing, manipulating, and constructing URLs. It is part of the KDE Frameworks package library.QString scheme = "https"; QString host = "www.example.com"; int port = 443; QString path = "/path/to/some/page.html"; QString query = "query=value"; QString fragment = "fragment"; KUrl url; url.setScheme(scheme); url.setHost(host); url.setPort(port); url.setPath(path); url.setQuery(query); url.setFragment(fragment); QString urlStr = url.url(); // "https://www.example.com/path/to/some/page.html?query=value#fragment"