#include#include KUrl url("https://www.example.com/"); url.addPath("folder/subfolder/file.txt"); KIO::CopyJob *job = KIO::copy(url, KUrl("file:///home/user/Downloads/file.txt")); job->start();
#includeIn this example, we're adding multiple path segments ("api", "get_data", "user") and a query parameter ("id") to the URL. The result is a final URL string with all the added components. Package library: KUrlKUrl url("https://www.example.com/"); url.addPath("api"); url.addPath("get_data"); url.addPath("user"); url.addQueryItem("id", "123"); QString urlString = url.prettyUrl(); // Output: "https://www.example.com/api/get_data/user?id=123"