QUrl url = QUrl("/path/to/file.txt"); if (url.isRelative()) { // Do something with the relative URL }
QUrl url = QUrl("https://www.google.com/search?q=qt+url+isrelative"); if (!url.isRelative()) { // Do something with the absolute URL }In this example, a QUrl object is created with an absolute URL "https://www.google.com/search?q=qt+url+isrelative". The isRelative method is called on the object, which will return false. The QUrl class is part of the Qt Network module, which is included in the Qt Core library.