Q3Url Class Reference
|
Функция | Returns |
---|---|
protocol() | "http" |
host() | "example.com" |
port() | 80 |
path() | "/cgi-bin/test me.pl" |
fileName() | "test me.pl" |
query() | "cmd=Hello%20you" |
Пример:
<tt>http://qt.nokia.com/doc/qdockarea.html#lines</tt>
Функция | Returns |
---|---|
protocol() | "http" |
host() | "qt.nokia.com" |
fileName() | "doc/qdockarea.html" |
ref() | "lines" |
The individual parts of a URL can be set with setProtocol(), setHost(), setPort(), setPath(), setFileName(), setRef() and setQuery(). A URL could contain, for example, an ftp address which requires a user name and password; these can be set with setUser() and setPassword().
Because path is always encoded internally you must not use "%00" in the path, although this is okay (but not recommended) for the query.
Q3Url is normally used like this:
Q3Url url( "http://qt.nokia.com" ); // or Q3Url url( "file:///home/myself/Mail", "Inbox" );
You can then access and manipulate the various parts of the URL.
To make it easy to work with Q3Urls and QStrings, Q3Url implements the necessary cast and assignment operators so you can do following:
Q3Url url( "http://qt.nokia.com" ); QString s = url; // or QString s( "http://qt.nokia.com" ); Q3Url url( s );
Use the static functions, encode() and decode() to encode or decode a URL in a string. (They operate on the string in-place.) The isRelativeUrl() static function returns true if the given string is a relative URL.
If you want to use a URL to work on a hierarchical structure (e.g. a local or remote filesystem), you might want to use the subclass Q3UrlOperator.
See also Q3UrlOperator.
Constructs an empty URL that is invalid.
Constructs a URL by parsing the string url.
If you pass a string like "/home/qt", the "file" protocol is assumed.
Copy constructor. Copies the data of url.
Constructs an URL taking url as the base (context) and relUrl as a relative URL to url. If relUrl is not relative, relUrl is taken as the new URL.
For example, the path of
Q3Url url( "ftp://ftp.qt.nokia.com/qt/source", "qt-2.1.0.tar.gz" );
will be "/qt/srource/qt-2.1.0.tar.gz".
On the other hand,
Q3Url url( "ftp://ftp.qt.nokia.com/qt/source", "/usr/local" );
will result in a new URL, "ftp://ftp.qt.nokia.com/usr/local", because "/usr/local" isn't relative.
Similarly,
Q3Url url( "ftp://ftp.qt.nokia.com/qt/source", "file:///usr/local" );
will result in a new URL, with "/usr/local" as the path and "file" as the 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 the constructor to handle the last part of the path as a file name if there is no slash at the end, and to let it be replaced by the file name of relUrl (if it contains one), set checkSlash to true.
Деструктор.
Adds the path pa to the path of the URL.
See also setPath() and hasPath().
Changes the directory to one directory up. This function always returns true.
Смотрите также setPath().
Decodes the url in-place into UTF-8. For example
QString url = "http%3A//qt%20nokia%20com" Q3Url::decode( url ); // url is now "http://qt.nokia.com"
See also encode().
Returns the directory path of the URL. This is the part of the path of the URL without the fileName(). See the documentation of fileName() for a discussion of what is handled as file name and what is handled as directory path.
See also setPath() and hasPath().
Encodes the url in-place into UTF-8. For example
QString url = http://qt.nokia.com Q3Url::encode( url ); // url is now "http%3A//qt%20nokia%20com"
See also decode().
Returns the encoded path and query.
See also setEncodedPathAndQuery() and decode().
Returns the file name 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 considered to be the file name. If the path has a slash at the end, an empty string is returned here.
Смотрите также setFileName().
Returns true if the URL contains a hostname; otherwise returns false.
See also setHost().
Returns true if the URL contains a password; otherwise returns false.
Warning: Passwords passed in URLs are normally insecure; this is due to the mechanism, not because of Qt.
See also setPassword() and setUser().
Returns true if the URL contains a path; otherwise returns false.
See also path() and setPath().
Returns true if the URL contains a port; otherwise returns false.
Смотрите также setPort().
Returns true if the URL has a reference; otherwise returns false.
See also setRef().
Returns true if the URL contains a username; otherwise returns false.
See also setUser() and setPassword().
Returns the hostname of the URL.
See also setHost() and hasHost().
Returns true if the URL is a local file; otherwise returns false.
Returns true if url is relative; otherwise returns false.
Returns true if the URL is valid; otherwise returns false. A URL is invalid if it cannot be parsed, for example.
Parses the url. Возвращает true, если всё прошло успешно; в противном случае возвращает false.
Returns the password of the URL.
Warning: Passwords passed in URLs are normally insecure; this is due to the mechanism, not because of Qt.
See also setPassword() and setUser().
Returns the path of the URL. If correct is true, the path is cleaned (deals with too many or too few slashes, cleans things like "/../..", etc). Otherwise path() returns exactly the path that was parsed or set.
See also setPath() and hasPath().
Returns the port of the URL or -1 if no port has been set.
Смотрите также setPort().
Returns the protocol of the URL. Typically, "file", "http", "ftp", etc.
See also setProtocol().
Returns the (encoded) query of the URL.
See also setQuery() and decode().
Returns the (encoded) reference of the URL.
See also setRef(), hasRef(), and decode().
Resets all parts of the URL to their default values and invalidates it.
Parses pathAndQuery for a path and query and sets those values. The whole string must be encoded.
See also encodedPathAndQuery() and encode().
Sets the file name of the URL to name. If this URL contains a fileName(), the original file name is replaced by name.
See the documentation of fileName() for a more detailed discussion of what is handled as file name and what is handled as a directory path.
See also fileName().
Sets the hostname of the URL to host.
See also host() and hasHost().
Sets the password of the URL to pass.
Warning: Passwords passed in URLs are normally insecure; this is due to the mechanism, not because of Qt.
See also password() and setUser().
Sets the path of the URL to path.
See also path() and hasPath().
Sets the port of the URL to port.
See also port().
Sets the protocol of the URL to protocol. Typically, "file", "http", "ftp", etc.
See also protocol().
Sets the query of the URL to txt. txt must be encoded.
See also query() and encode().
Sets the reference of the URL to txt. txt must be encoded.
See also ref(), hasRef(), and encode().
Sets the username of the URL to user.
See also user() and setPassword().
Composes a string version of the URL and returns it. If encodedPath is true the path in the returned string is encoded. If forcePrependProtocol is true and encodedPath looks like a local filename, the "file:/" protocol is also prepended.
See also encode() and decode().
Returns the username of the URL.
See also setUser() and setPassword().
Composes a string version of the URL and returns it.
See also Q3Url::toString().
Assigns the data of url to this class.
Это перегруженная функция.
Parses url and assigns the resulting data to this class.
If you pass a string like "/home/qt" the "file" protocol will be assumed.
Compares this URL with url and returns true if they are equal; otherwise returns false.
Это перегруженная функция.
Compares this URL with url. url is parsed first. Returns true if url is equal to this url; otherwise returns false.
Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies) | Торговые марки | Qt 4.5.3 |
Попытка перевода Qt документации. Если есть желание присоединиться, или если есть замечания или пожелания, то заходите на форум: Перевод Qt документации на русский язык... Люди внесшие вклад в перевод: Команда переводчиков |