⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 qurl.html

📁 QT 下载资料仅供参考
💻 HTML
📖 第 1 页 / 共 2 页
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><!-- /home/reggie/tmp/qt-3.0-reggie-5401/qt-x11-commercial-3.0.5/src/kernel/qurl.cpp:92 --><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>QUrl Class</title><style type="text/css"><!--h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }a:link { color: #004faf; text-decoration: none }a:visited { color: #672967; text-decoration: none }body { background: #ffffff; color: black; }--></style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr bgcolor="#E5E5E5"><td valign=center> <a href="index.html"><font color="#004faf">Home</font></a> | <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a> | <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a> | <a href="annotated.html"><font color="#004faf">Annotated</font></a> | <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a> | <a href="functions.html"><font color="#004faf">Functions</font></a></td><td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QUrl Class Reference<br><small>[<a href="network.html">network module</a>]</small></h1><p>The QUrl class provides a URL parser and simplifies working with URLs.<a href="#details">More...</a><p><tt>#include &lt;<a href="qurl-h.html">qurl.h</a>&gt;</tt><p>Inherited by <a href="qurloperator.html">QUrlOperator</a>.<p><a href="qurl-members.html">List of all member functions.</a><h2>Public Members</h2><ul><li><div class=fn><a href="#QUrl"><b>QUrl</b></a> ()</div></li><li><div class=fn><a href="#QUrl-2"><b>QUrl</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;url )</div></li><li><div class=fn><a href="#QUrl-3"><b>QUrl</b></a> ( const&nbsp;QUrl&nbsp;&amp;&nbsp;url )</div></li><li><div class=fn><a href="#QUrl-4"><b>QUrl</b></a> ( const&nbsp;QUrl&nbsp;&amp;&nbsp;url, const&nbsp;QString&nbsp;&amp;&nbsp;relUrl, bool&nbsp;checkSlash = FALSE )</div></li><li><div class=fn>virtual <a href="#~QUrl"><b>~QUrl</b></a> ()</div></li><li><div class=fn>QString <a href="#protocol"><b>protocol</b></a> () const</div></li><li><div class=fn>virtual void <a href="#setProtocol"><b>setProtocol</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;protocol )</div></li><li><div class=fn>QString <a href="#user"><b>user</b></a> () const</div></li><li><div class=fn>virtual void <a href="#setUser"><b>setUser</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;user )</div></li><li><div class=fn>bool <a href="#hasUser"><b>hasUser</b></a> () const</div></li><li><div class=fn>QString <a href="#password"><b>password</b></a> () const</div></li><li><div class=fn>virtual void <a href="#setPassword"><b>setPassword</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;pass )</div></li><li><div class=fn>bool <a href="#hasPassword"><b>hasPassword</b></a> () const</div></li><li><div class=fn>QString <a href="#host"><b>host</b></a> () const</div></li><li><div class=fn>virtual void <a href="#setHost"><b>setHost</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;host )</div></li><li><div class=fn>bool <a href="#hasHost"><b>hasHost</b></a> () const</div></li><li><div class=fn>int <a href="#port"><b>port</b></a> () const</div></li><li><div class=fn>virtual void <a href="#setPort"><b>setPort</b></a> ( int&nbsp;port )</div></li><li><div class=fn>bool <a href="#hasPort"><b>hasPort</b></a> () const</div></li><li><div class=fn>QString <a href="#path"><b>path</b></a> ( bool&nbsp;correct = TRUE ) const</div></li><li><div class=fn>virtual void <a href="#setPath"><b>setPath</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;path )</div></li><li><div class=fn>bool <a href="#hasPath"><b>hasPath</b></a> () const</div></li><li><div class=fn>virtual void <a href="#setEncodedPathAndQuery"><b>setEncodedPathAndQuery</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;pathAndQuery )</div></li><li><div class=fn>QString <a href="#encodedPathAndQuery"><b>encodedPathAndQuery</b></a> ()</div></li><li><div class=fn>virtual void <a href="#setQuery"><b>setQuery</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;txt )</div></li><li><div class=fn>QString <a href="#query"><b>query</b></a> () const</div></li><li><div class=fn>QString <a href="#ref"><b>ref</b></a> () const</div></li><li><div class=fn>virtual void <a href="#setRef"><b>setRef</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;txt )</div></li><li><div class=fn>bool <a href="#hasRef"><b>hasRef</b></a> () const</div></li><li><div class=fn>bool <a href="#isValid"><b>isValid</b></a> () const</div></li><li><div class=fn>bool <a href="#isLocalFile"><b>isLocalFile</b></a> () const</div></li><li><div class=fn>virtual void <a href="#addPath"><b>addPath</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;pa )</div></li><li><div class=fn>virtual void <a href="#setFileName"><b>setFileName</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;name )</div></li><li><div class=fn>QString <a href="#fileName"><b>fileName</b></a> () const</div></li><li><div class=fn>QString <a href="#dirPath"><b>dirPath</b></a> () const</div></li><li><div class=fn>QUrl &amp; <a href="#operator-eq"><b>operator=</b></a> ( const&nbsp;QUrl&nbsp;&amp;&nbsp;url )</div></li><li><div class=fn>QUrl &amp; <a href="#operator-eq-2"><b>operator=</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;url )</div></li><li><div class=fn>bool <a href="#operator-eq-eq"><b>operator==</b></a> ( const&nbsp;QUrl&nbsp;&amp;&nbsp;url ) const</div></li><li><div class=fn>bool <a href="#operator-eq-eq-2"><b>operator==</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;url ) const</div></li><li><div class=fn><a href="#operator-QString"><b>operator QString</b></a> () const</div></li><li><div class=fn>virtual QString <a href="#toString"><b>toString</b></a> ( bool&nbsp;encodedPath = FALSE, bool&nbsp;forcePrependProtocol = TRUE ) const</div></li><li><div class=fn>virtual bool <a href="#cdUp"><b>cdUp</b></a> ()</div></li></ul><h2>Static Public Members</h2><ul><li><div class=fn>void <a href="#decode"><b>decode</b></a> ( QString&nbsp;&amp;&nbsp;url )</div></li><li><div class=fn>void <a href="#encode"><b>encode</b></a> ( QString&nbsp;&amp;&nbsp;url )</div></li><li><div class=fn>bool <a href="#isRelativeUrl"><b>isRelativeUrl</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;url )</div></li></ul><h2>Protected Members</h2><ul><li><div class=fn>virtual void <a href="#reset"><b>reset</b></a> ()</div></li><li><div class=fn>virtual bool <a href="#parse"><b>parse</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;url )</div></li></ul><hr><a name="details"></a><h2>Detailed Description</h2><p> The QUrl class provides a URL parser and simplifies working with URLs.<p> <p> <p> The QUrl class is provided for simple work with URLs. It canparse, decode, encode, etc.<p> QUrl works with the decoded path and encoded query in turn.<p> Example:<p> <tt>http://www.trolltech.com:80/cgi-bin/test%20me.pl?cmd=Hello%20you</tt><p> <center><table cellpadding="4" cellspacing="2" border="0"><tr bgcolor="#a2c511"> <th valign="top">Function	    <th valign="top">Returns<tr bgcolor="#f0f0f0"> <td valign="top"><a href="#protocol">protocol</a>()   <td valign="top">"http"<tr bgcolor="#d0d0d0"> <td valign="top"><a href="#host">host</a>()	    <td valign="top">"www.trolltech.com"<tr bgcolor="#f0f0f0"> <td valign="top"><a href="#port">port</a>()	    <td valign="top">80<tr bgcolor="#d0d0d0"> <td valign="top"><a href="#path">path</a>()	    <td valign="top">"cgi-bin"<tr bgcolor="#f0f0f0"> <td valign="top"><a href="#fileName">fileName</a>()   <td valign="top">"test&nbsp;me.pl"<tr bgcolor="#d0d0d0"> <td valign="top"><a href="#query">query</a>()	    <td valign="top">"cmd=Hello%20you"</table></center><p> Example:<p> <tt>http://doc.trolltech.com/qdockarea.html#lines</tt><p> <center><table cellpadding="4" cellspacing="2" border="0"><tr bgcolor="#a2c511"> <th valign="top">Function	    <th valign="top">Returns<tr bgcolor="#f0f0f0"> <td valign="top"><a href="#protocol">protocol</a>()   <td valign="top">"http"<tr bgcolor="#d0d0d0"> <td valign="top"><a href="#host">host</a>()	    <td valign="top">"doc.trolltech.com"<tr bgcolor="#f0f0f0"> <td valign="top"><a href="#fileName">fileName</a>()   <td valign="top">"qdockarea.html"<tr bgcolor="#d0d0d0"> <td valign="top"><a href="#ref">ref</a>()	    <td valign="top">"lines"</table></center><p> The individual parts of a URL can be set with <a href="#setProtocol">setProtocol</a>(),<a href="#setHost">setHost</a>(), <a href="#setPort">setPort</a>(), <a href="#setPath">setPath</a>(), <a href="#setFileName">setFileName</a>(), <a href="#setRef">setRef</a>() and<a href="#setQuery">setQuery</a>(). A URL could contain, for example, an ftp address whichrequires a user name and password; these can be set with <a href="#setUser">setUser</a>()and <a href="#setPassword">setPassword</a>().<p> Because path is always encoded internally you must not use "%00"in the path, although this is okay (but not recommended) for thequery.<p> QUrl is normally used like this:<p> <pre>    QUrl url( "http://www.trolltech.com" );    // or    QUrl url( "file:/home/myself/Mail", "Inbox" );    </pre> <p> You can then access and manipulate the various parts of the URL.<p> To make it easy to work with QUrls and QStrings, QUrl implementsthe necessary cast and assignment operators so you can dofollowing:<p> <pre>    QUrl url( "http://www.trolltech.com" );    <a href="qstring.html">QString</a> s = url;    // or    <a href="qstring.html">QString</a> s( "http://www.trolltech.com" );    QUrl url( s );    </pre> <p> Use the static functions, <a href="#encode">encode</a>() and <a href="#decode">decode</a>() to encode ordecode a URL in a string. (They operate on the string in-place.)The <a href="#isRelativeUrl">isRelativeUrl</a>() static function returns TRUE if the givenstring is a relative URL.<p> 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<a href="qurloperator.html">QUrlOperator</a>.<p> <p>See also <a href="qurloperator.html">QUrlOperator</a>, <a href="io.html">Input/Output and Networking</a> and <a href="misc.html">Miscellaneous Classes</a>.<hr><h2>Member Function Documentation</h2><h3 class=fn><a name="QUrl"></a>QUrl::QUrl ()</h3>Constructs an empty URL that is invalid.<h3 class=fn><a name="QUrl-2"></a>QUrl::QUrl ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;url )</h3>Constructs a URL by parsing the string <em>url</em>.<p> If you pass a string like "/home/qt", the "file" protocol isassumed.<h3 class=fn><a name="QUrl-3"></a>QUrl::QUrl ( const&nbsp;<a href="qurl.html">QUrl</a>&nbsp;&amp;&nbsp;url )</h3>Copy constructor. Copies the data of <em>url</em>.<h3 class=fn><a name="QUrl-4"></a>QUrl::QUrl ( const&nbsp;<a href="qurl.html">QUrl</a>&nbsp;&amp;&nbsp;url, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;relUrl, bool&nbsp;checkSlash = FALSE )</h3>Constructs an URL taking <em>url</em> as the base (context) and<em>relUrl</em> as a relative URL to <em>url</em>. If <em>relUrl</em> is not relative,<em>relUrl</em> is taken as the new URL.<p> For example, the path of<pre>    QUrl url( "ftp://ftp.trolltech.com/qt/source", "qt-2.1.0.tar.gz" );    </pre> will be "/qt/srource/qt-2.1.0.tar.gz".<p> On the other hand,<pre>    QUrl url( "ftp://ftp.trolltech.com/qt/source", "/usr/local" );    </pre> will result in a new URL, "ftp://ftp.trolltech.com/usr/local",because "/usr/local" isn't relative.<p> Similarly,<pre>    QUrl url( "ftp://ftp.trolltech.com/qt/source", "file:/usr/local" );    </pre> will result in a new URL, with "/usr/local" as the pathand "file" as the protocol.<p> Normally it is expected that the path of <em>url</em> points to adirectory, even if the path has no slash at the end. But if youwant the constructor to handle the last part of the path as a filename if there is no slash at the end, and to let it be replaced bythe file name of <em>relUrl</em> (if it contains one), set <em>checkSlash</em>to TRUE.<h3 class=fn><a name="~QUrl"></a>QUrl::~QUrl ()<tt> [virtual]</tt></h3>Destructor.<h3 class=fn>void <a name="addPath"></a>QUrl::addPath ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;pa )<tt> [virtual]</tt></h3>Adds the path <em>pa</em> to the path of the URL.<p> <p>See also <a href="#setPath">setPath</a>() and <a href="#hasPath">hasPath</a>().<h3 class=fn>bool <a name="cdUp"></a>QUrl::cdUp ()<tt> [virtual]</tt></h3>Changes the directory to one directory up.<p> <p>See also <a href="#setPath">setPath</a>().<h3 class=fn>void <a name="decode"></a>QUrl::decode ( <a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;url )<tt> [static]</tt></h3>Decodes the string <em>url</em> <em>in-place</em>.<p> <p>See also <a href="#encode">encode</a>().<h3 class=fn><a href="qstring.html">QString</a> <a name="dirPath"></a>QUrl::dirPath () const</h3>Returns the directory path of the URL. This is the part of thepath of the URL without the <a href="#fileName">fileName</a>(). See the documentation offileName() for a discussion of what is handled as file name and

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -