aboutsummaryrefslogtreecommitdiffstats
path: root/doc/codesnippets/doc/src/snippets/code/src_corelib_io_qurl.cpp
blob: a56843816b877aa102bcaad9c3888d1be9c42e36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//! [0]
url = QUrl("http://www.example.com/List of holidays.xml")
# url.toEncoded() == "http://www.example.com/List%20of%20holidays.xml"
//! [0]


//! [1]
url = QUrl.fromEncoded("http://qtsoftware.com/List%20of%20holidays.xml")
//! [1]


//! [2]
def checkUrl(url):
    if !url.isValid():
        print QString("Invalid URL: %1").arg(url.toString())
        return false

    return true

//! [2]


//! [3]
ftp = QFtp()
ftp.connectToHost(url.host(), url.port(21))
//! [3]


//! [4]
http://www.example.com/cgi-bin/drawgraph.cgi?type-pie/color-green
//! [4]


//! [5]
baseUrl = QUrl("http://qtsoftware.com/support")
relativeUrl = QUrl("../products/solutions")
print baseUrl.resolved(relativeUrl).toString()
# prints "http://qtsoftware.com/products/solutions"
//! [5]


//! [6]
ba = QUrl.toPercentEncoding("{a fishy string?}", "{}", "s")
print ba.constData()
# prints "{a fi%73hy %73tring%3F}"
//! [6]