QUrl url; url.setUrl("https://www.example.com/path/to/resource");
QUrl url; url.setScheme("ftp"); url.setHost("localhost"); url.setPath("/data/file.txt");In this example, we create a new QUrl object and use the setScheme, setHost, and setPath functions to set its protocol to "ftp", its hostname to "localhost", and its path to "/data/file.txt". The QUrl class is part of the Qt Core module, which is included in the Qt library.