📄 qurl.3qt
字号:
.TH QUrl 3qt "10 November 2000" "Trolltech AS" \" -*- nroff -*-.\" Copyright 1992-2000 Trolltech AS. All rights reserved. See the.\" license file included in the distribution for a complete license.\" statement..\".ad l.nh.SH NAMEQUrl \- Mainly an URL parser and simplifies working with URLs.SH SYNOPSIS.br.PP\fC#include <qurl.h>\fR.PPInherited by QUrlOperator..PP.SS "Public Members".in +1c.ti -1c.BI "\fBQUrl\fR () ".br.ti -1c.BI "\fBQUrl\fR ( const QString & url ) ".br.ti -1c.BI "\fBQUrl\fR ( const QUrl & url ) ".br.ti -1c.BI "\fBQUrl\fR ( const QUrl & " "url" ", const QString & " "relUrl" ", bool " "checkSlash" " = FALSE ) ".br.ti -1c.BI "virtual \fB~QUrl\fR () ".br.ti -1c.BI "QString \fBprotocol\fR () const".br.ti -1c.BI "virtual void \fBsetProtocol\fR ( const QString & protocol ) ".br.ti -1c.BI "QString \fBuser\fR () const".br.ti -1c.BI "virtual void \fBsetUser\fR ( const QString & user ) ".br.ti -1c.BI "bool \fBhasUser\fR () const".br.ti -1c.BI "QString \fBpassword\fR () const".br.ti -1c.BI "virtual void \fBsetPassword\fR ( const QString & pass ) ".br.ti -1c.BI "bool \fBhasPassword\fR () const".br.ti -1c.BI "QString \fBhost\fR () const".br.ti -1c.BI "virtual void \fBsetHost\fR ( const QString & user ) ".br.ti -1c.BI "bool \fBhasHost\fR () const".br.ti -1c.BI "int \fBport\fR () const".br.ti -1c.BI "virtual void \fBsetPort\fR ( int port ) ".br.ti -1c.BI "QString \fBpath\fR ( bool " "correct" " = TRUE ) const".br.ti -1c.BI "virtual void \fBsetPath\fR ( const QString & path ) ".br.ti -1c.BI "bool \fBhasPath\fR () const".br.ti -1c.BI "virtual void \fBsetEncodedPathAndQuery\fR ( const QString & enc ) ".br.ti -1c.BI "QString \fBencodedPathAndQuery\fR () ".br.ti -1c.BI "virtual void \fBsetQuery\fR ( const QString & txt ) ".br.ti -1c.BI "QString \fBquery\fR () const".br.ti -1c.BI "QString \fBref\fR () const".br.ti -1c.BI "virtual void \fBsetRef\fR ( const QString & txt ) ".br.ti -1c.BI "bool \fBhasRef\fR () const".br.ti -1c.BI "bool \fBisValid\fR () const".br.ti -1c.BI "bool \fBisLocalFile\fR () const".br.ti -1c.BI "virtual void \fBaddPath\fR ( const QString & path ) ".br.ti -1c.BI "virtual void \fBsetFileName\fR ( const QString & txt ) ".br.ti -1c.BI "QString \fBfileName\fR () const".br.ti -1c.BI "QString \fBdirPath\fR () const".br.ti -1c.BI "QUrl& \fBoperator=\fR ( const QUrl & url ) ".br.ti -1c.BI "QUrl& \fBoperator=\fR ( const QString & url ) ".br.ti -1c.BI "bool \fBoperator==\fR ( const QUrl & url ) const".br.ti -1c.BI "bool \fBoperator==\fR ( const QString & url ) const".br.ti -1c.BI "operator \fBQString\fR ()const".br.ti -1c.BI "virtual QString \fBtoString\fR ( bool " "encodedPath" " = FALSE, bool " "forcePrependProtocol" " = TRUE ) const".br.ti -1c.BI "virtual bool \fBcdUp\fR () ".br.in -1c.SS "Static Public Members".in +1c.ti -1c.BI "void \fBdecode\fR ( QString & url ) ".br.ti -1c.BI "void \fBencode\fR ( QString & url ) ".br.ti -1c.BI "bool \fBisRelativeUrl\fR ( const QString & url ) ".br.in -1c.SS "Protected Members".in +1c.ti -1c.BI "virtual void \fBreset\fR () ".br.ti -1c.BI "virtual bool \fBparse\fR ( const QString & url ) ".br.in -1c.SH DESCRIPTIONThe QUrl class provides mainly an URL parser and simplifies working with URLs..PPThe QUrl class is provided for a easy working with URLs. It does all parsing, decoding, encoding and so on..PPMention that URL has some restrictions regarding the path encoding. URL works intern with the decoded path and and encoded query. For example in.PPhttp://localhost/cgi-bin/test%20me.pl?cmd=Hello%20you.PPwould 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..PPQUrl is normally used like that:.PP.nf.br QUrl u( "http://www.trolltech.com" );.br // or.br QUrl u( "file:/home/myself/Mail", "Inbox" );.fi.PPThen you can access the parts of the URL, change them and do some more stuff..PPTo allow easy working with QUrl and QString together, QUrl implements the needed cast and assign operators. So you can do following:.PP.nf.br QUrl u( "http://www.trolltech.com" );.br QString s = u;.br // or.br QString s( "http://www.trolltech.com" );.br QUrl u( s );.fi.PPIf 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..PPSee also QUrlOperator..SH MEMBER FUNCTION DOCUMENTATION.SH "QUrl::QUrl ()"Constructs an empty URL which, is invalid..SH "QUrl::QUrl ( const QString & url )"Constructs and URL using \fIurl\fR and parses this string..PPYou can pass strings like "/home/qt", in this case the protocol "file" is assumed..SH "QUrl::QUrl ( const QUrl & url )"Copy constructor. Copies the data of \fIurl.\fR.SH "QUrl::QUrl ( const QUrl & url, const QString & relUrl, bool checkSlash = FALSE )"Constructs and URL taking \fIurl\fR as base (context) and \fIrelUrl\fR as relative URL to \fIurl.\fR If \fIrelUrl\fR is not relative, \fIrelUrl\fR is taken as new URL..PPFor example, the path of.PP.nf.br QUrl u( "ftp://ftp.trolltech.com/qt/source", "qt-2.1.0.tar.gz" );.fi.PPwill be "/qt/srource/qt-2.1.0.tar.gz"..PPAnd.PP.nf.br QUrl u( "ftp://ftp.trolltech.com/qt/source", "/usr/local" );.fi.PPwill result in a new URL, "ftp://ftp.trolltech.com/usr/local",.PPAnd.PP.nf.br QUrl u( "ftp://ftp.trolltech.com/qt/source", "file:/usr/local" );.fi.PPwill result in a new URL, with "/usr/local" as path and "file" as protocol..PPNormally it is expected that the path of \fIurl\fR 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 \fIrelUrl\fR (if it contains one), set \fIcheckSlash\fR to TRUE..SH "QUrl::~QUrl () \fC[virtual]\fR"Destructor..SH "QUrl::operator QString () const"Composes a string of the URL and returns it..PPSee also QUrl::toString()..SH "void QUrl::addPath ( const QString & pa ) \fC[virtual]\fR"Adds the path \fIpa\fR to the path of the URL..SH "bool QUrl::cdUp () \fC[virtual]\fR"Goes one directory up..SH "void QUrl::decode ( QString & url ) \fC[static]\fR"Decodes the string \fIurl.\fR.SH "QString QUrl::dirPath () const"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..SH "void QUrl::encode ( QString & url ) \fC[static]\fR"Encodes the string \fIurl.\fR.SH "QString QUrl::encodedPathAndQuery ()"Returns the encoded path plus the query (encoded too)..SH "QString QUrl::fileName () const"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..SH "bool QUrl::hasHost () const"Returns TRUE, if the URL contains a hostname, else FALSE;..SH "bool QUrl::hasPassword () const"Returns TRUE, if the URL contains a password, else FALSE;..SH "bool QUrl::hasPath () const"Returns TRUE, if the URL contains a path, else FALSE..SH "bool QUrl::hasRef () const"Returns TRUE, if the URL has a reference, else it returns FALSE..SH "bool QUrl::hasUser () const"Returns TRUE, if the URL contains an username, else FALSE;..SH "QString QUrl::host () const"Returns the hostname of the URL..SH "bool QUrl::isLocalFile () const"Returns TRUE, if the URL is a local file, else it returns FALSE;..SH "bool QUrl::isRelativeUrl ( const QString & url ) \fC[static]\fR"Returns TRUE, if \fIurl\fR is relative, else it returns FALSE..SH "bool QUrl::isValid () const"Returns TRUE if the URL is valid, else FALSE. An URL is e.g. invalid if there was a parse error..SH "QUrl& QUrl::operator= ( const QString & url )"Assign operator. Parses \fIurl\fR and assigns the resulting data to this class..PPYou can pass strings like "/home/qt", in this case the protocol "file" is assumed..SH "QUrl& QUrl::operator= ( const QUrl & url )"Assign operator. Assigns the data of \fIurl\fR to this class..SH "bool QUrl::operator== ( const QString & url ) const"Compares this URL with \fIurl. url\fR is parsed first. Returns TRUE if \fIurl\fR is equal to this url, else FALSE:..SH "bool QUrl::operator== ( const QUrl & url ) const"Compares this URL with \fIurl\fR and returns TRUE if they are equal, else FALSE..SH "bool QUrl::parse ( const QString & url ) \fC[virtual protected]\fR"Parses the \fIurl.\fR.SH "QString QUrl::password () const"Returns the password of the URL..SH "QString QUrl::path ( bool correct = TRUE ) const"Returns the path of the URL. If \fIcorrect\fR 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..SH "int QUrl::port () const"Returns the port of the URL..SH "QString QUrl::protocol () const"Returns the protocol of the URL. It is something like "file" or "ftp"..SH "QString QUrl::query () const"Returns the query (encoded) of the URL..SH "QString QUrl::ref () const"Returns the reference (encoded) of the URL..SH "void QUrl::reset () \fC[virtual protected]\fR"Resets all values if the URL to its default values and invalidates it..SH "void QUrl::setEncodedPathAndQuery ( const QString & path ) \fC[virtual]\fR"Sets path and query. Both have to be encoded..SH "void QUrl::setFileName ( const QString & name ) \fC[virtual]\fR"Sets the filename of the URL to \fIname.\fR If this url contains a fileName(), this is replaced by \fIname.\fR See the documentation of fileName() for a more detail discussion, about what is handled as file name and what as directory path..SH "void QUrl::setHost ( const QString & host ) \fC[virtual]\fR"Sets the hostname of the URL..SH "void QUrl::setPassword ( const QString & pass ) \fC[virtual]\fR"Sets the password of the URL..SH "void QUrl::setPath ( const QString & path ) \fC[virtual]\fR"Sets the path or the URL..SH "void QUrl::setPort ( int port ) \fC[virtual]\fR"Sets the port of the URL..SH "void QUrl::setProtocol ( const QString & protocol ) \fC[virtual]\fR"Sets the protocol of the URL. This could be e.g. "file", "ftp", or something similar..SH "void QUrl::setQuery ( const QString & txt ) \fC[virtual]\fR"Sets the query of the URL. Must be encoded..SH "void QUrl::setRef ( const QString & txt ) \fC[virtual]\fR"Sets the reference of the URL. Must be encoded..SH "void QUrl::setUser ( const QString & user ) \fC[virtual]\fR"Sets the username of the URL..SH "QString QUrl::toString ( bool encodedPath = FALSE, bool forcePrependProtocol = TRUE ) const \fC[virtual]\fR"Composes a string of the URL and returns it. If \fIencodedPath\fR is TRUE, the path in the returned string will be encoded. If \fIforcePrependProtocol\fR is TRUE, the protocol (file:/) is also prepended to local filenames, else no protocol is prepended for local filenames..SH "QString QUrl::user () const"Returns the username of the URL..SH "SEE ALSO".BR http://doc.trolltech.com/qurl.html.SH COPYRIGHTCopyright 1992-2000 Trolltech AS, http://www.trolltech.com/. See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -