summaryrefslogtreecommitdiffstats
path: root/doc/src/snippets/code/src_corelib_io_qurl.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'doc/src/snippets/code/src_corelib_io_qurl.cpp')
-rw-r--r--doc/src/snippets/code/src_corelib_io_qurl.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/doc/src/snippets/code/src_corelib_io_qurl.cpp b/doc/src/snippets/code/src_corelib_io_qurl.cpp
new file mode 100644
index 0000000..95de86c
--- /dev/null
+++ b/doc/src/snippets/code/src_corelib_io_qurl.cpp
@@ -0,0 +1,47 @@
+//! [0]
+QUrl url("http://www.example.com/List of holidays.xml");
+// url.toEncoded() == "http://www.example.com/List%20of%20holidays.xml"
+//! [0]
+
+
+//! [1]
+QUrl url = QUrl::fromEncoded("http://qtsoftware.com/List%20of%20holidays.xml");
+//! [1]
+
+
+//! [2]
+bool checkUrl(const QUrl &url) {
+ if (!url.isValid()) {
+ qDebug(QString("Invalid URL: %1").arg(url.toString()));
+ return false;
+ }
+
+ return true;
+}
+//! [2]
+
+
+//! [3]
+QFtp ftp;
+ftp.connectToHost(url.host(), url.port(21));
+//! [3]
+
+
+//! [4]
+http://www.example.com/cgi-bin/drawgraph.cgi?type-pie/color-green
+//! [4]
+
+
+//! [5]
+QUrl baseUrl("http://qtsoftware.com/support");
+QUrl relativeUrl("../products/solutions");
+qDebug(baseUrl.resolved(relativeUrl).toString());
+// prints "http://qtsoftware.com/products/solutions"
+//! [5]
+
+
+//! [6]
+QByteArray ba = QUrl::toPercentEncoding("{a fishy string?}", "{}", "s");
+qDebug(ba.constData());
+// prints "{a fi%73hy %73tring%3F}"
+//! [6]