QUrl Class Reference
|
Function | Returns |
---|---|
protocol() | "http" |
host() | "www.trolltech.com" |
port() | 80 |
path() | "/cgi-bin/test me.pl" |
fileName() | "test me.pl" |
query() | "cmd=Hello%20you" |
Example:
http://doc.trolltech.com/qdockarea.html#lines
Function | Returns |
---|---|
protocol() | "http" |
host() | "doc.trolltech.com" |
fileName() | "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.
QUrl is normally used like this:
QUrl url( "http://www.trolltech.com" ); // or QUrl 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 QUrls and QStrings, QUrl implements the necessary cast and assignment operators so you can do following:
QUrl url( "http://www.trolltech.com" ); QString s = url; // or QString s( "http://www.trolltech.com" ); QUrl 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 QUrlOperator.
See also QUrlOperator, Input/Output and Networking, and Miscellaneous Classes.
If you pass a string like "/home/qt", the "file" protocol is assumed.
For example, the path of
QUrl url( "ftp://ftp.trolltech.com/qt/source", "qt-2.1.0.tar.gz" );will be "/qt/srource/qt-2.1.0.tar.gz".
On the other hand,
QUrl url( "ftp://ftp.trolltech.com/qt/source", "/usr/local" );will result in a new URL, "ftp://ftp.trolltech.com/usr/local", because "/usr/local" isn't relative.
Similarly,
QUrl url( "ftp://ftp.trolltech.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.
See also setPath() and hasPath().
See also setPath().
QString url = "http%3A//www%20trolltech%20com" QUrl::decode( url ); // url is now "http://www.trolltech.com"
See also encode().
See also setPath() and hasPath().
Example: network/networkprotocol/nntp.cpp.
QString url = http://www.trolltech.com QUrl::encode( url ); // url is now "http%3A//www%20trolltech%20com"
See also decode().
Example: network/archivesearch/archivedialog.ui.h.
See also decode().
See also setFileName().
Example: network/networkprotocol/nntp.cpp.
See also setHost().
Warning: Passwords passed in URLs are normally insecure; this is due to the mechanism, not because of Qt.
See also setPassword() and setUser().
See also path() and setPath().
See also setPort().
See also setRef().
See also setUser() and setPassword().
See also setHost() and hasHost().
Example: network/archivesearch/archivedialog.ui.h.
Example: qdir/qdir.cpp.
See also QUrl::toString().
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. url is parsed first. Returns TRUE if url is equal to this url; 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().
See also setPath() and hasPath().
Example: qdir/qdir.cpp.
See also setPort().
See also setProtocol().
See also setQuery() and decode().
See also setRef(), hasRef(), and decode().
See also encode().
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().
See also host() and hasHost().
Warning: Passwords passed in URLs are normally insecure; this is due to the mechanism, not because of Qt.
See also password() and setUser().
See also path() and hasPath().
See also port().
See also protocol().
See also query() and encode().
See also ref(), hasRef(), and encode().
See also user() and setPassword().
See also encode() and decode().
See also setUser() and setPassword().
This file is part of the Qt toolkit. Copyright © 1995-2003 Trolltech. All Rights Reserved.
Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. | Qt 3.2 | |
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD. | ||
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP ! |
Copyright © 2000-2012 - www.developpez.com