The QUrl class provides mainly an URL parser and simplifies working with URLs. More...
#include <qurl.h>
Inherited by QUrlOperator.
The QUrl class is provided for a easy working with URLs. It does all parsing, decoding, encoding and so on.
Mention that URL has some restrictions regarding the path encoding. URL works intern with the decoded path and and encoded query. For example in
http://localhost/cgi-bin/test%20me.pl?cmd=Hello%20you
would result in a decoded path "/cgi-bin/test me.pl" and in the encoded query "cmd=Hello%20you". Since path is internally always encoded you may NOT use "%00" in the path while this is ok for the query.
QUrl is normally used like that:
QUrl u( "http://www.trolltech.com" ); // or QUrl u( "file:/home/myself/Mail", "Inbox" );
Then you can access the parts of the URL, change them and do some more stuff.
To allow easy working with QUrl and QString together, QUrl implements the needed cast and assign operators. So you can do following:
QUrl u( "http://www.trolltech.com" ); QString s = u; // or QString s( "http://www.trolltech.com" ); QUrl u( s );
If you want to use an URL to work on a hierarchical structures (e.g. locally or remote filesystem) the class QUrlOperator, which is derived fro QUrl, may be interesting for you.
See also QUrlOperator.
Constructs an empty URL which, is invalid.
Constructs and URL using url and parses this string.
You can pass strings like "/home/qt", in this case the protocol "file" is assumed.
Copy constructor. Copies the data of url.
Constructs and URL taking url as base (context) and relUrl as relative URL to url. If relUrl is not relative, relUrl is taken as new URL.
For example, the path of
QUrl u( "ftp://ftp.trolltech.com/qt/source", "qt-2.1.0.tar.gz" );
will be "/qt/srource/qt-2.1.0.tar.gz".
And
QUrl u( "ftp://ftp.trolltech.com/qt/source", "/usr/local" );
will result in a new URL, "ftp://ftp.trolltech.com/usr/local",
And
QUrl u( "ftp://ftp.trolltech.com/qt/source", "file:/usr/local" );
will result in a new URL, with "/usr/local" as path and "file" as protocol.
Normally it is expected that the path of url points to a directory, even if the path has no slash at the end. But if you want that the constructor handles the last part of the path as filename, if there is no slash at the end, and let it replace by the filename of relUrl (if it contains one), set checkSlash to TRUE.
[virtual]
Destructor.
Composes a string of the URL and returns it.
See also QUrl::toString().
[virtual]
Adds the path pa to the path of the URL.
[virtual]
Goes one directory up.
[static]
Decodes the string url.
Returns the directory path of the URL. This is the part of the path of this URL without the fileName(). See the documentation of fileName() for a discussion what is handled as file name and what as directory path.
[static]
Encodes the string url.
Returns the encoded path plus the query (encoded too).
Returns the filename of the URL. If the path of the URL doesn't have a slash at the end, the part between the last slash and the end of the path string is handled as filename. If the path has a slash at the end, an empty string is returned here.
Returns TRUE, if the URL contains a hostname, else FALSE;.
Returns TRUE, if the URL contains a password, else FALSE;.
Returns TRUE, if the URL contains a path, else FALSE.
Returns TRUE, if the URL has a reference, else it returns FALSE.
Returns TRUE, if the URL contains an username, else FALSE;.
Returns the hostname of the URL.
Returns TRUE, if the URL is a local file, else it returns FALSE;.
[static]
Returns TRUE, if url is relative, else it returns FALSE.
Returns TRUE if the URL is valid, else FALSE. An URL is e.g. invalid if there was a parse error.
Assign operator. Parses url and assigns the resulting data to this class.
You can pass strings like "/home/qt", in this case the protocol "file" is assumed.
Assign operator. Assigns the data of url to this class.
Compares this URL with url. url is parsed first. Returns TRUE if url is equal to this url, else FALSE:.
Compares this URL with url and returns TRUE if they are equal, else FALSE.
[virtual protected]
Parses the url.
Returns the password of the URL.
Returns the path of the URL. If correct is TRUE, the path is cleaned (deals with too many or few slashes, cleans things like "/../..", etc). Else exactly the path which was parsed or set is returned.
Returns the port of the URL.
Returns the protocol of the URL. It is something like "file" or "ftp".
Returns the query (encoded) of the URL.
Returns the reference (encoded) of the URL.
[virtual protected]
Resets all values if the URL to its default values and invalidates it.
[virtual]
Sets path and query. Both have to be encoded.
[virtual]
Sets the filename of the URL to name. If this url contains a fileName(), this is replaced by name. See the documentation of fileName() for a more detail discussion, about what is handled as file name and what as directory path.
[virtual]
Sets the hostname of the URL.
[virtual]
Sets the password of the URL.
[virtual]
Sets the path or the URL.
[virtual]
Sets the port of the URL.
[virtual]
Sets the protocol of the URL. This could be e.g. "file", "ftp", or something similar.
[virtual]
Sets the query of the URL. Must be encoded.
[virtual]
Sets the reference of the URL. Must be encoded.
[virtual]
Sets the username of the URL.
[virtual]
Composes a string of the URL and returns it. If encodedPath is TRUE, the path in the returned string will be encoded. If forcePrependProtocol is TRUE, the protocol (file:/) is also prepended to local filenames, else no protocol is prepended for local filenames.
Returns the username of the URL.
Search the documentation, FAQ, qt-interest archive and more (uses
www.trolltech.com):
This file is part of the Qt toolkit, copyright © 1995-2000 Trolltech, all rights reserved.
Copyright İ 2000 Trolltech | Trademarks | Qt version 2.2.1
|