1QUrl(3qt)                                                            QUrl(3qt)
2
3
4

NAME

6       QUrl - URL parser and simplifies working with URLs
7

SYNOPSIS

9       #include <qurl.h>
10
11       Inherited by QUrlOperator.
12
13   Public Members
14       QUrl ()
15       QUrl ( const QString & url )
16       QUrl ( const QUrl & url )
17       QUrl ( const QUrl & url, const QString & relUrl, bool checkSlash =
18           FALSE )
19       virtual ~QUrl ()
20       QString protocol () const
21       virtual void setProtocol ( const QString & protocol )
22       QString user () const
23       virtual void setUser ( const QString & user )
24       bool hasUser () const
25       QString password () const
26       virtual void setPassword ( const QString & pass )
27       bool hasPassword () const
28       QString host () const
29       virtual void setHost ( const QString & host )
30       bool hasHost () const
31       int port () const
32       virtual void setPort ( int port )
33       bool hasPort () const
34       QString path ( bool correct = TRUE ) const
35       virtual void setPath ( const QString & path )
36       bool hasPath () const
37       virtual void setEncodedPathAndQuery ( const QString & pathAndQuery )
38       QString encodedPathAndQuery ()
39       virtual void setQuery ( const QString & txt )
40       QString query () const
41       QString ref () const
42       virtual void setRef ( const QString & txt )
43       bool hasRef () const
44       bool isValid () const
45       bool isLocalFile () const
46       virtual void addPath ( const QString & pa )
47       virtual void setFileName ( const QString & name )
48       QString fileName () const
49       QString dirPath () const
50       QUrl & operator= ( const QUrl & url )
51       QUrl & operator= ( const QString & url )
52       bool operator== ( const QUrl & url ) const
53       bool operator== ( const QString & url ) const
54       operator QString () const
55       virtual QString toString ( bool encodedPath = FALSE, bool
56           forcePrependProtocol = TRUE ) const
57       virtual bool cdUp ()
58
59   Static Public Members
60       void decode ( QString & url )
61       void encode ( QString & url )
62       bool isRelativeUrl ( const QString & url )
63
64   Protected Members
65       virtual void reset ()
66       virtual bool parse ( const QString & url )
67

DESCRIPTION

69       The QUrl class provides a URL parser and simplifies working with URLs.
70
71       The QUrl class is provided for simple work with URLs. It can parse,
72       decode, encode, etc.
73
74       QUrl works with the decoded path and encoded query in turn.
75
76       Example:
77
78       http://www.trolltech.com:80/cgi-bin/test%20me.pl?cmd=Hello%20you
79
80       <center>.nf
81
82       </center>
83
84       Example:
85
86       http://doc.trolltech.com/qdockarea.html#lines
87
88       <center>.nf
89
90       </center>
91
92       The individual parts of a URL can be set with setProtocol(), setHost(),
93       setPort(), setPath(), setFileName(), setRef() and setQuery(). A URL
94       could contain, for example, an ftp address which requires a user name
95       and password; these can be set with setUser() and setPassword().
96
97       Because path is always encoded internally you must not use "%00" in the
98       path, although this is okay (but not recommended) for the query.
99
100       QUrl is normally used like this:
101
102           QUrl url( "http://www.trolltech.com" );
103           // or
104           QUrl url( "file:/home/myself/Mail", "Inbox" );
105
106       You can then access and manipulate the various parts of the URL.
107
108       To make it easy to work with QUrls and QStrings, QUrl implements the
109       necessary cast and assignment operators so you can do following:
110
111           QUrl url( "http://www.trolltech.com" );
112           QString s = url;
113           // or
114           QString s( "http://www.trolltech.com" );
115           QUrl url( s );
116
117       Use the static functions, encode() and decode() to encode or decode a
118       URL in a string. (They operate on the string in-place.) The
119       isRelativeUrl() static function returns TRUE if the given string is a
120       relative URL.
121
122       If you want to use a URL to work on a hierarchical structure (e.g. a
123       local or remote filesystem), you might want to use the subclass
124       QUrlOperator.
125
126       See also QUrlOperator, Input/Output and Networking, and Miscellaneous
127       Classes.
128

MEMBER FUNCTION DOCUMENTATION

QUrl::QUrl ()

131       Constructs an empty URL that is invalid.
132

QUrl::QUrl ( const QString & url )

134       Constructs a URL by parsing the string url.
135
136       If you pass a string like "/home/qt", the "file" protocol is assumed.
137

QUrl::QUrl ( const QUrl & url )

139       Copy constructor. Copies the data of url.
140

QUrl::QUrl ( const QUrl & url, const QString & relUrl, bool checkSlash = FALSE

142       )
143       Constructs an URL taking url as the base (context) and relUrl as a
144       relative URL to url. If relUrl is not relative, relUrl is taken as the
145       new URL.
146
147       For example, the path of
148
149           QUrl url( "ftp://ftp.trolltech.com/qt/source", "qt-2.1.0.tar.gz" );
150       will be "/qt/srource/qt-2.1.0.tar.gz".
151
152       On the other hand,
153
154           QUrl url( "ftp://ftp.trolltech.com/qt/source", "/usr/local" );
155       will result in a new URL, "ftp://ftp.trolltech.com/usr/local", because
156       "/usr/local" isn't relative.
157
158       Similarly,
159
160           QUrl url( "ftp://ftp.trolltech.com/qt/source", "file:/usr/local" );
161       will result in a new URL, with "/usr/local" as the path and "file" as
162       the protocol.
163
164       Normally it is expected that the path of url points to a directory,
165       even if the path has no slash at the end. But if you want the
166       constructor to handle the last part of the path as a file name if there
167       is no slash at the end, and to let it be replaced by the file name of
168       relUrl (if it contains one), set checkSlash to TRUE.
169

QUrl::~QUrl () [virtual]

171       Destructor.
172

void QUrl::addPath ( const QString & pa ) [virtual]

174       Adds the path pa to the path of the URL.
175
176       See also setPath() and hasPath().
177

bool QUrl::cdUp () [virtual]

179       Changes the directory to one directory up.
180
181       See also setPath().
182

void QUrl::decode ( QString & url ) [static]

184       Decodes the url in-place into UTF-8. For example
185
186               QString url = "http%3A//www%20trolltech%20com"
187               QUrl::decode( url );
188               // url is now "http://www.trolltech.com"
189
190       See also encode().
191

QString QUrl::dirPath () const

193       Returns the directory path of the URL. This is the part of the path of
194       the URL without the fileName(). See the documentation of fileName() for
195       a discussion of what is handled as file name and what is handled as
196       directory path.
197
198       See also setPath() and hasPath().
199
200       Example: network/networkprotocol/nntp.cpp.
201

void QUrl::encode ( QString & url ) [static]

203       Encodes the url in-place into UTF-8. For example
204
205               QString url = http://www.trolltech.com
206               QUrl::encode( url );
207               // url is now "http%3A//www%20trolltech%20com"
208
209       See also decode().
210
211       Example: network/archivesearch/archivedialog.ui.h.
212

QString QUrl::encodedPathAndQuery ()

214       Returns the encoded path and query.
215
216       See also decode().
217

QString QUrl::fileName () const

219       Returns the file name of the URL. If the path of the URL doesn't have a
220       slash at the end, the part between the last slash and the end of the
221       path string is considered to be the file name. If the path has a slash
222       at the end, an empty string is returned here.
223
224       See also setFileName().
225
226       Example: network/networkprotocol/nntp.cpp.
227

bool QUrl::hasHost () const

229       Returns TRUE if the URL contains a hostname; otherwise returns FALSE.
230
231       See also setHost().
232

bool QUrl::hasPassword () const

234       Returns TRUE if the URL contains a password; otherwise returns FALSE.
235
236       Warning: Passwords passed in URLs are normally insecure; this is due to
237       the mechanism, not because of Qt.
238
239       See also setPassword() and setUser().
240

bool QUrl::hasPath () const

242       Returns TRUE if the URL contains a path; otherwise returns FALSE.
243
244       See also path() and setPath().
245

bool QUrl::hasPort () const

247       Returns TRUE if the URL contains a port; otherwise returns FALSE.
248
249       See also setPort().
250

bool QUrl::hasRef () const

252       Returns TRUE if the URL has a reference; otherwise returns FALSE.
253
254       See also setRef().
255

bool QUrl::hasUser () const

257       Returns TRUE if the URL contains a username; otherwise returns FALSE.
258
259       See also setUser() and setPassword().
260

QString QUrl::host () const

262       Returns the hostname of the URL.
263
264       See also setHost() and hasHost().
265
266       Example: network/archivesearch/archivedialog.ui.h.
267

bool QUrl::isLocalFile () const

269       Returns TRUE if the URL is a local file; otherwise returns FALSE.
270
271       Example: qdir/qdir.cpp.
272

bool QUrl::isRelativeUrl ( const QString & url ) [static]

274       Returns TRUE if url is relative; otherwise returns FALSE.
275

bool QUrl::isValid () const

277       Returns TRUE if the URL is valid; otherwise returns FALSE. A URL is
278       invalid if it cannot be parsed, for example.
279

QUrl::operator QString () const

281       Composes a string version of the URL and returns it.
282
283       See also QUrl::toString().
284

QUrl & QUrl::operator= ( const QUrl & url )

286       Assigns the data of url to this class.
287

QUrl & QUrl::operator= ( const QString & url )

289       This is an overloaded member function, provided for convenience. It
290       behaves essentially like the above function.
291
292       Parses url and assigns the resulting data to this class.
293
294       If you pass a string like "/home/qt" the "file" protocol will be
295       assumed.
296

bool QUrl::operator== ( const QUrl & url ) const

298       Compares this URL with url and returns TRUE if they are equal;
299       otherwise returns FALSE.
300

bool QUrl::operator== ( const QString & url ) const

302       This is an overloaded member function, provided for convenience. It
303       behaves essentially like the above function.
304
305       Compares this URL with url. url is parsed first. Returns TRUE if url is
306       equal to this url; otherwise returns FALSE.
307

bool QUrl::parse ( const QString & url ) [virtual protected]

309       Parses the url.
310

QString QUrl::password () const

312       Returns the password of the URL.
313
314       Warning: Passwords passed in URLs are normally insecure; this is due to
315       the mechanism, not because of Qt.
316
317       See also setPassword() and setUser().
318

QString QUrl::path ( bool correct = TRUE ) const

320       Returns the path of the URL. If correct is TRUE, the path is cleaned
321       (deals with too many or too few slashes, cleans things like "/../..",
322       etc). Otherwise path() returns exactly the path that was parsed or set.
323
324       See also setPath() and hasPath().
325
326       Example: qdir/qdir.cpp.
327

int QUrl::port () const

329       Returns the port of the URL or -1 if no port has been set.
330
331       See also setPort().
332

QString QUrl::protocol () const

334       Returns the protocol of the URL. Typically, "file", "http", "ftp", etc.
335
336       See also setProtocol().
337

QString QUrl::query () const

339       Returns the (encoded) query of the URL.
340
341       See also setQuery() and decode().
342

QString QUrl::ref () const

344       Returns the (encoded) reference of the URL.
345
346       See also setRef(), hasRef(), and decode().
347

void QUrl::reset () [virtual protected]

349       Resets all parts of the URL to their default values and invalidates it.
350

void QUrl::setEncodedPathAndQuery ( const QString & pathAndQuery ) [virtual]

352       Parses pathAndQuery for a path and query and sets those values. The
353       whole string must be encoded.
354
355       See also encode().
356

void QUrl::setFileName ( const QString & name ) [virtual]

358       Sets the file name of the URL to name. If this URL contains a
359       fileName(), the original file name is replaced by name.
360
361       See the documentation of fileName() for a more detailed discussion of
362       what is handled as file name and what is handled as a directory path.
363
364       See also fileName().
365

void QUrl::setHost ( const QString & host ) [virtual]

367       Sets the hostname of the URL to host.
368
369       See also host() and hasHost().
370

void QUrl::setPassword ( const QString & pass ) [virtual]

372       Sets the password of the URL to pass.
373
374       Warning: Passwords passed in URLs are normally insecure; this is due to
375       the mechanism, not because of Qt.
376
377       See also password() and setUser().
378

void QUrl::setPath ( const QString & path ) [virtual]

380       Sets the path of the URL to path.
381
382       See also path() and hasPath().
383

void QUrl::setPort ( int port ) [virtual]

385       Sets the port of the URL to port.
386
387       See also port().
388

void QUrl::setProtocol ( const QString & protocol ) [virtual]

390       Sets the protocol of the URL to protocol. Typically, "file"," http",
391       "ftp", etc.
392
393       See also protocol().
394

void QUrl::setQuery ( const QString & txt ) [virtual]

396       Sets the query of the URL to txt. txt must be encoded.
397
398       See also query() and encode().
399

void QUrl::setRef ( const QString & txt ) [virtual]

401       Sets the reference of the URL to txt. txt must be encoded.
402
403       See also ref(), hasRef(), and encode().
404

void QUrl::setUser ( const QString & user ) [virtual]

406       Sets the username of the URL to user.
407
408       See also user() and setPassword().
409

QString QUrl::toString ( bool encodedPath = FALSE, bool forcePrependProtocol =

411       TRUE ) const [virtual]
412       Composes a string version of the URL and returns it. If encodedPath is
413       TRUE the path in the returned string is encoded. If
414       forcePrependProtocol is TRUE and encodedPath looks like a local
415       filename, the "file:/" protocol is also prepended.
416
417       See also encode() and decode().
418

QString QUrl::user () const

420       Returns the username of the URL.
421
422       See also setUser() and setPassword().
423
424

SEE ALSO

426       http://doc.trolltech.com/qurl.html
427       http://www.trolltech.com/faq/tech.html
428
430       Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com.  See the
431       license file included in the distribution for a complete license
432       statement.
433

AUTHOR

435       Generated automatically from the source code.
436

BUGS

438       If you find a bug in Qt, please report it as described in
439       http://doc.trolltech.com/bughowto.html.  Good bug reports help us to
440       help you. Thank you.
441
442       The definitive Qt documentation is provided in HTML format; it is
443       located at $QTDIR/doc/html and can be read using Qt Assistant or with a
444       web browser. This man page is provided as a convenience for those users
445       who prefer man pages, although this format is not officially supported
446       by Trolltech.
447
448       If you find errors in this manual page, please report them to qt-
449       bugs@trolltech.com.  Please include the name of the manual page
450       (qurl.3qt) and the Qt version (3.3.8).
451
452
453
454Trolltech AS                    2 February 2007                      QUrl(3qt)
Impressum