KURL url("https://www.example.com/path?param1=value1¶m2=value2#fragment"); std::cout << url.protocol() << std::endl; // prints "https:" std::cout << url.host() << std::endl; // prints "www.example.com" std::cout << url.path() << std::endl; // prints "/path" std::cout << url.query() << std::endl; // prints "param1=value1¶m2=value2" std::cout << url.fragmentIdentifier() << std::endl; // prints "fragment"
KURL url; url.setProtocol("https:"); url.setHost("www.example.com"); url.setPath("/path"); url.addQueryParameter("param1", "value1"); url.addQueryParameter("param2", "value2"); url.setFragmentIdentifier("fragment"); std::cout << url.string() << std::endl; // prints "https://www.example.com/path?param1=value1¶m2=value2#fragment"This example demonstrates how to build a URL by setting its components using KURL library. In order to use KURL library, you need to link against the "kurl" package, which is typically a part of the KDE Frameworks.