📄 qurl.3qt
字号:
Constructs a URL by parsing the string \fIurl\fR..PPIf you pass a string like "/home/qt", the "file" protocol 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 an URL taking \fIurl\fR as the base (context) and \fIrelUrl\fR as a relative URL to \fIurl\fR. If \fIrelUrl\fR is not relative, \fIrelUrl\fR is taken as the new URL..PPFor example, the path of.PP.nf.br QUrl url( "ftp://ftp.trolltech.com/qt/source", "qt-2.1.0.tar.gz" );.br.fiwill be "/qt/srource/qt-2.1.0.tar.gz"..PPOn the other hand,.PP.nf.br QUrl url( "ftp://ftp.trolltech.com/qt/source", "/usr/local" );.br.fiwill result in a new URL, "ftp://ftp.trolltech.com/usr/local", because "/usr/local" isn't relative..PPSimilarly,.PP.nf.br QUrl url( "ftp://ftp.trolltech.com/qt/source", "file:/usr/local" );.br.fiwill result in a new URL, with "/usr/local" as the path and "file" as the 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 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 \fIrelUrl\fR (if it contains one), set \fIcheckSlash\fR to TRUE..SH "QUrl::~QUrl ()\fC [virtual]\fR"Destructor..SH "void QUrl::addPath ( const QString & pa )\fC [virtual]\fR"Adds the path \fIpa\fR to the path of the URL..PPSee also setPath() and hasPath()..SH "bool QUrl::cdUp ()\fC [virtual]\fR"Changes the directory to one directory up..PPSee also setPath()..SH "void QUrl::decode ( QString & url )\fC [static]\fR"Decodes the string \fIurl\fR \fIin-place\fR..PPSee also encode()..SH "QString QUrl::dirPath () const"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..PPSee also setPath() and hasPath()..PPExample: network/networkprotocol/nntp.cpp..SH "void QUrl::encode ( QString & url )\fC [static]\fR"Encodes the string \fIurl\fR \fIin-place\fR..PPSee also decode()..SH "QString QUrl::encodedPathAndQuery ()"Returns the encoded path and query..PPSee also decode()..SH "QString QUrl::fileName () const"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..PPSee also setFileName()..PPExample: network/networkprotocol/nntp.cpp..SH "bool QUrl::hasHost () const"Returns TRUE if the URL contains a hostname; otherwise returns FALSE..PPSee also setHost()..SH "bool QUrl::hasPassword () const"Returns TRUE if the URL contains a password; otherwise returns FALSE..PP\fBWarning:\fR Passwords passed in URLs are normally \fIinsecure\fR; this is due to the mechanism, not because of Qt..PPSee also setPassword() and setUser()..SH "bool QUrl::hasPath () const"Returns TRUE if the URL contains a path; otherwise returns FALSE..PPSee also path() and setPath()..SH "bool QUrl::hasPort () const"Returns TRUE if the URL contains a port; otherwise returns FALSE..PPSee also setPort()..SH "bool QUrl::hasRef () const"Returns TRUE if the URL has a reference; otherwise returns FALSE..PPSee also setRef()..SH "bool QUrl::hasUser () const"Returns TRUE if the URL contains a username; otherwise returns FALSE..PPSee also setUser() and setPassword()..SH "QString QUrl::host () const"Returns the hostname of the URL..PPSee also setHost() and hasHost()..SH "bool QUrl::isLocalFile () const"Returns TRUE if the URL is a local file; otherwise returns FALSE..PPExample: qdir/qdir.cpp..SH "bool QUrl::isRelativeUrl ( const QString & url )\fC [static]\fR"Returns TRUE if \fIurl\fR is relative; otherwise returns FALSE..SH "bool QUrl::isValid () const"Returns TRUE if the URL is valid; otherwise returns FALSE. A URL is invalid if it cannot be parsed, for example..SH "QUrl::operator QString () const"Composes a string version of the URL and returns it..PPSee also QUrl::toString()..SH "QUrl & QUrl::operator= ( const QUrl & url )"Assigns the data of \fIurl\fR to this class..SH "QUrl & QUrl::operator= ( const QString & url )"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPParses \fIurl\fR and assigns the resulting data to this class..PPIf you pass a string like "/home/qt" the "file" protocol will be assumed..SH "bool QUrl::operator== ( const QUrl & url ) const"Compares this URL with \fIurl\fR and returns TRUE if they are equal; otherwise returns FALSE..SH "bool QUrl::operator== ( const QString & url ) const"This is an overloaded member function, provided for convenience. It behaves essentially like the above function..PPCompares this URL with \fIurl\fR. \fIurl\fR is parsed first. Returns TRUE if \fIurl\fR is equal to this url; otherwise returns 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..PP\fBWarning:\fR Passwords passed in URLs are normally \fIinsecure\fR; this is due to the mechanism, not because of Qt..PPSee also setPassword() and setUser()..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 too few slashes, cleans things like "/../..", etc). Otherwise path() returns exactly the path that was parsed or set..PPSee also setPath() and hasPath()..PPExample: qdir/qdir.cpp..SH "int QUrl::port () const"Returns the port of the URL or -1 if no port has been set..PPSee also setPort()..SH "QString QUrl::protocol () const"Returns the protocol of the URL. Typically, "file", "http", "ftp", etc..PPSee also setProtocol()..SH "QString QUrl::query () const"Returns the (encoded) query of the URL..PPSee also setQuery() and decode()..SH "QString QUrl::ref () const"Returns the (encoded) reference of the URL..PPSee also setRef(), hasRef(), and decode()..SH "void QUrl::reset ()\fC [virtual protected]\fR"Resets all parts of the URL to their default values and invalidates it..SH "void QUrl::setEncodedPathAndQuery ( const QString & pathAndQuery )\fC [virtual]\fR"Parses \fIpathAndQuery\fR for a path and query and sets those values. The whole string must be encoded..PPSee also encode()..SH "void QUrl::setFileName ( const QString & name )\fC [virtual]\fR"Sets the file name of the URL to \fIname\fR. If this URL contains a fileName(), the original file name is replaced by \fIname\fR..PPSee the documentation of fileName() for a more detailed discussion of what is handled as file name and what is handled as a directory path..PPSee also fileName()..SH "void QUrl::setHost ( const QString & host )\fC [virtual]\fR"Sets the hostname of the URL to \fIhost\fR..PPSee also host() and hasHost()..SH "void QUrl::setPassword ( const QString & pass )\fC [virtual]\fR"Sets the password of the URL to \fIpass\fR..PP\fBWarning:\fR Passwords passed in URLs are normally \fIinsecure\fR; this is due to the mechanism, not because of Qt..PPSee also password() and setUser()..SH "void QUrl::setPath ( const QString & path )\fC [virtual]\fR"Sets the path of the URL to \fIpath\fR..PPSee also path() and hasPath()..SH "void QUrl::setPort ( int port )\fC [virtual]\fR"Sets the port of the URL to \fIport\fR..PPSee also port()..SH "void QUrl::setProtocol ( const QString & protocol )\fC [virtual]\fR"Sets the protocol of the URL to \fIprotocol\fR. Typically, "file"," http", "ftp", etc..PPSee also protocol()..SH "void QUrl::setQuery ( const QString & txt )\fC [virtual]\fR"Sets the query of the URL to \fItxt\fR. \fItxt\fR must be encoded..PPSee also query() and encode()..SH "void QUrl::setRef ( const QString & txt )\fC [virtual]\fR"Sets the reference of the URL to \fItxt\fR. \fItxt\fR must be encoded..PPSee also ref(), hasRef(), and encode()..SH "void QUrl::setUser ( const QString & user )\fC [virtual]\fR"Sets the username of the URL to \fIuser\fR..PPSee also user() and setPassword()..SH "QString QUrl::toString ( bool encodedPath = FALSE, bool forcePrependProtocol = TRUE ) const\fC [virtual]\fR"Composes a string version of the URL and returns it. If \fIencodedPath\fR is TRUE the path in the returned string is encoded. If \fIforcePrependProtocol\fR is TRUE and \fIencodedPath\fR looks like a local filename, the "file:/" protocol is also prepended..PPSee also encode() and decode()..SH "QString QUrl::user () const"Returns the username of the URL..PPSee also setUser() and setPassword()..SH "SEE ALSO".BR http://doc.trolltech.com/qurl.html.BR http://www.trolltech.com/faq/tech.html.SH COPYRIGHTCopyright 1992-2001 Trolltech AS, http://www.trolltech.com. See thelicense file included in the distribution for a complete licensestatement..SH AUTHORGenerated automatically from the source code..SH BUGSIf you find a bug in Qt, please report it as described in.BR http://doc.trolltech.com/bughowto.html .Good bug reports help us to help you. Thank you..PThe definitive Qt documentation is provided in HTML format; it islocated at $QTDIR/doc/html and can be read using Qt Assistant or witha web browser. This man page is provided as a convenience for thoseusers who prefer man pages, although this format is not officiallysupported by Trolltech. .PIf you find errors in this manual page, please report them to.BR qt-bugs@trolltech.com .Please include the name of the manual page (qurl.3qt) and the Qtversion (3.1.1).
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -