<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!-- q3url.cpp --> <title>Qt 4.8: Q3Url Class Reference</title> <link rel="stylesheet" type="text/css" href="style/style.css" /> <script src="scripts/jquery.js" type="text/javascript"></script> <script src="scripts/functions.js" type="text/javascript"></script> <link rel="stylesheet" type="text/css" href="style/superfish.css" /> <link rel="stylesheet" type="text/css" href="style/narrow.css" /> <!--[if IE]> <meta name="MSSmartTagsPreventParsing" content="true"> <meta http-equiv="imagetoolbar" content="no"> <![endif]--> <!--[if lt IE 7]> <link rel="stylesheet" type="text/css" href="style/style_ie6.css"> <![endif]--> <!--[if IE 7]> <link rel="stylesheet" type="text/css" href="style/style_ie7.css"> <![endif]--> <!--[if IE 8]> <link rel="stylesheet" type="text/css" href="style/style_ie8.css"> <![endif]--> <script src="scripts/superfish.js" type="text/javascript"></script> <script src="scripts/narrow.js" type="text/javascript"></script> </head> <body class="" onload="CheckEmptyAndLoadList();"> <div class="header" id="qtdocheader"> <div class="content"> <div id="nav-logo"> <a href="index.html">Home</a></div> <a href="index.html" class="qtref"><span>Qt Reference Documentation</span></a> <div id="narrowsearch"></div> <div id="nav-topright"> <ul> <li class="nav-topright-home"><a href="http://qt.digia.com/">Qt HOME</a></li> <li class="nav-topright-dev"><a href="http://qt-project.org/">DEV</a></li> <li class="nav-topright-doc nav-topright-doc-active"><a href="http://qt-project.org/doc/"> DOC</a></li> <li class="nav-topright-blog"><a href="http://blog.qt.digia.com/">BLOG</a></li> </ul> </div> <div id="shortCut"> <ul> <li class="shortCut-topleft-inactive"><span><a href="index.html">Qt 4.8</a></span></li> <li class="shortCut-topleft-active"><a href="http://qt-project.org/doc/">ALL VERSIONS </a></li> </ul> </div> <ul class="sf-menu" id="narrowmenu"> <li><a href="#">API Lookup</a> <ul> <li><a href="classes.html">Class index</a></li> <li><a href="functions.html">Function index</a></li> <li><a href="modules.html">Modules</a></li> <li><a href="namespaces.html">Namespaces</a></li> <li><a href="qtglobal.html">Global Declarations</a></li> <li><a href="qdeclarativeelements.html">QML elements</a></li> </ul> </li> <li><a href="#">Qt Topics</a> <ul> <li><a href="qt-basic-concepts.html">Programming with Qt</a></li> <li><a href="qtquick.html">Device UIs & Qt Quick</a></li> <li><a href="qt-gui-concepts.html">UI Design with Qt</a></li> <li><a href="supported-platforms.html">Supported Platforms</a></li> <li><a href="technology-apis.html">Qt and Key Technologies</a></li> <li><a href="best-practices.html">How-To's and Best Practices</a></li> </ul> </li> <li><a href="#">Examples</a> <ul> <li><a href="all-examples.html">Examples</a></li> <li><a href="tutorials.html">Tutorials</a></li> <li><a href="demos.html">Demos</a></li> <li><a href="qdeclarativeexamples.html">QML Examples</a></li> </ul> </li> </ul> </div> </div> <div class="wrapper"> <div class="hd"> <span></span> </div> <div class="bd group"> <div class="sidebar"> <div class="searchlabel"> Search index:</div> <div class="search" id="sidebarsearch"> <form id="qtdocsearch" action="" onsubmit="return false;"> <fieldset> <input type="text" name="searchstring" id="pageType" value="" /> <div id="resultdialog"> <a href="#" id="resultclose">Close</a> <p id="resultlinks" class="all"><a href="#" id="showallresults">All</a> | <a href="#" id="showapiresults">API</a> | <a href="#" id="showarticleresults">Articles</a> | <a href="#" id="showexampleresults">Examples</a></p> <p id="searchcount" class="all"><span id="resultcount"></span><span id="apicount"></span><span id="articlecount"></span><span id="examplecount"></span> results:</p> <ul id="resultlist" class="all"> </ul> </div> </fieldset> </form> </div> <div class="box first bottombar" id="lookup"> <h2 title="API Lookup"><span></span> API Lookup</h2> <div id="list001" class="list"> <ul id="ul001" > <li class="defaultLink"><a href="classes.html">Class index</a></li> <li class="defaultLink"><a href="functions.html">Function index</a></li> <li class="defaultLink"><a href="modules.html">Modules</a></li> <li class="defaultLink"><a href="namespaces.html">Namespaces</a></li> <li class="defaultLink"><a href="qtglobal.html">Global Declarations</a></li> <li class="defaultLink"><a href="qdeclarativeelements.html">QML elements</a></li> </ul> </div> </div> <div class="box bottombar" id="topics"> <h2 title="Qt Topics"><span></span> Qt Topics</h2> <div id="list002" class="list"> <ul id="ul002" > <li class="defaultLink"><a href="qt-basic-concepts.html">Programming with Qt</a></li> <li class="defaultLink"><a href="qtquick.html">Device UIs & Qt Quick</a></li> <li class="defaultLink"><a href="qt-gui-concepts.html">UI Design with Qt</a></li> <li class="defaultLink"><a href="supported-platforms.html">Supported Platforms</a></li> <li class="defaultLink"><a href="technology-apis.html">Qt and Key Technologies</a></li> <li class="defaultLink"><a href="best-practices.html">How-To's and Best Practices</a></li> </ul> </div> </div> <div class="box" id="examples"> <h2 title="Examples"><span></span> Examples</h2> <div id="list003" class="list"> <ul id="ul003"> <li class="defaultLink"><a href="all-examples.html">Examples</a></li> <li class="defaultLink"><a href="tutorials.html">Tutorials</a></li> <li class="defaultLink"><a href="demos.html">Demos</a></li> <li class="defaultLink"><a href="qdeclarativeexamples.html">QML Examples</a></li> </ul> </div> </div> </div> <div class="wrap"> <div class="toolbar"> <div class="breadcrumb toolblock"> <ul> <li class="first"><a href="index.html">Home</a></li> <!-- Breadcrumbs go here --> <li><a href="modules.html">Modules</a></li> <li>Qt3SupportLight</li> <li>Q3Url</li> </ul> </div> <div class="toolbuttons toolblock"> <ul> <li id="smallA" class="t_button">A</li> <li id="medA" class="t_button active">A</li> <li id="bigA" class="t_button">A</li> <li id="print" class="t_button"><a href="javascript:this.print();"> <span>Print</span></a></li> </ul> </div> </div> <div class="content mainContent"> <div class="toc"> <h3><a name="toc">Contents</a></h3> <ul> <li class="level1"><a href="#public-functions">Public Functions</a></li> <li class="level1"><a href="#static-public-members">Static Public Members</a></li> <li class="level1"><a href="#protected-functions">Protected Functions</a></li> <li class="level1"><a href="#details">Detailed Description</a></li> </ul> </div> <h1 class="title">Q3Url Class Reference</h1> <!-- $$$Q3Url-brief --> <p>The Q3Url class provides a URL parser and simplifies working with URLs. <a href="#details">More...</a></p> <!-- @@@Q3Url --> <pre class="cpp"> <span class="preprocessor">#include <Q3Url></span></pre><p><b>This class is part of the Qt 3 support library.</b> It is provided to keep old source code working. We strongly advise against using it in new code. See <a href="porting4.html#qurl">Porting to Qt 4</a> for more information.</p> <p><b>Inherited by: </b><a href="q3urloperator.html">Q3UrlOperator</a>.</p> <ul> <li><a href="q3url-members.html">List of all members, including inherited members</a></li> </ul> <a name="public-functions"></a> <h2>Public Functions</h2> <table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="q3url.html#Q3Url">Q3Url</a></b> ()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="q3url.html#Q3Url-2">Q3Url</a></b> ( const QString & <i>url</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="q3url.html#Q3Url-3">Q3Url</a></b> ( const Q3Url & <i>url</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="q3url.html#Q3Url-4">Q3Url</a></b> ( const Q3Url & <i>url</i>, const QString & <i>relUrl</i>, bool <i>checkSlash</i> = false )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual </td><td class="memItemRight bottomAlign"><b><a href="q3url.html#dtor.Q3Url">~Q3Url</a></b> ()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="q3url.html#addPath">addPath</a></b> ( const QString & <i>pa</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="q3url.html#cdUp">cdUp</a></b> ()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="q3url.html#dirPath">dirPath</a></b> () const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="q3url.html#encodedPathAndQuery">encodedPathAndQuery</a></b> ()</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="q3url.html#fileName">fileName</a></b> () const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="q3url.html#hasHost">hasHost</a></b> () const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="q3url.html#hasPassword">hasPassword</a></b> () const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="q3url.html#hasPath">hasPath</a></b> () const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="q3url.html#hasPort">hasPort</a></b> () const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="q3url.html#hasRef">hasRef</a></b> () const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="q3url.html#hasUser">hasUser</a></b> () const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="q3url.html#host">host</a></b> () const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="q3url.html#isLocalFile">isLocalFile</a></b> () const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="q3url.html#isValid">isValid</a></b> () const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="q3url.html#password">password</a></b> () const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="q3url.html#pathx">path</a></b> ( bool <i>correct</i> = true ) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="q3url.html#port">port</a></b> () const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="q3url.html#protocol">protocol</a></b> () const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="q3url.html#query">query</a></b> () const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="q3url.html#ref">ref</a></b> () const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="q3url.html#setEncodedPathAndQuery">setEncodedPathAndQuery</a></b> ( const QString & <i>pathAndQuery</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="q3url.html#setFileName">setFileName</a></b> ( const QString & <i>name</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="q3url.html#setHost">setHost</a></b> ( const QString & <i>host</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="q3url.html#setPassword">setPassword</a></b> ( const QString & <i>pass</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="q3url.html#setPath">setPath</a></b> ( const QString & <i>path</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="q3url.html#setPort">setPort</a></b> ( int <i>port</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="q3url.html#setProtocol">setProtocol</a></b> ( const QString & <i>protocol</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="q3url.html#setQuery">setQuery</a></b> ( const QString & <i>txt</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="q3url.html#setRef">setRef</a></b> ( const QString & <i>txt</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="q3url.html#setUser">setUser</a></b> ( const QString & <i>user</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual QString </td><td class="memItemRight bottomAlign"><b><a href="q3url.html#toString">toString</a></b> ( bool <i>encodedPath</i> = false, bool <i>forcePrependProtocol</i> = true ) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="q3url.html#user">user</a></b> () const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="q3url.html#operator-QString">operator QString</a></b> () const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> Q3Url & </td><td class="memItemRight bottomAlign"><b><a href="q3url.html#operator-eq">operator=</a></b> ( const Q3Url & <i>url</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> Q3Url & </td><td class="memItemRight bottomAlign"><b><a href="q3url.html#operator-eq-2">operator=</a></b> ( const QString & <i>url</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="q3url.html#operator-eq-eq">operator==</a></b> ( const Q3Url & <i>url</i> ) const</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="q3url.html#operator-eq-eq-2">operator==</a></b> ( const QString & <i>url</i> ) const</td></tr> </table> <a name="static-public-members"></a> <h2>Static Public Members</h2> <table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="q3url.html#decode">decode</a></b> ( QString & <i>url</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="q3url.html#encode">encode</a></b> ( QString & <i>url</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="q3url.html#isRelativeUrl">isRelativeUrl</a></b> ( const QString & <i>url</i> )</td></tr> </table> <a name="protected-functions"></a> <h2>Protected Functions</h2> <table class="alignedsummary"> <tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="q3url.html#parse">parse</a></b> ( const QString & <i>url</i> )</td></tr> <tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="q3url.html#reset">reset</a></b> ()</td></tr> </table> <a name="details"></a> <!-- $$$Q3Url-description --> <div class="descr"> <h2>Detailed Description</h2> <p>The Q3Url class provides a URL parser and simplifies working with URLs.</p> <p>The Q3Url class is provided for simple work with URLs. It can parse, decode, encode, etc.</p> <p>Q3Url works with the decoded path and encoded query in turn.</p> <p>Example:</p> <p><tt>http://example.com:80/cgi-bin/test%20me.pl?cmd=Hello%20you</tt></p> <table class="generic"> <thead><tr class="qt-style"><th >Function</th><th >Returns</th></tr></thead> <tr valign="top" class="odd"><td ><a href="q3url.html#protocol">protocol</a>()</td><td >"http"</td></tr> <tr valign="top" class="even"><td ><a href="q3url.html#host">host</a>()</td><td >"example.com"</td></tr> <tr valign="top" class="odd"><td ><a href="q3url.html#port">port</a>()</td><td >80</td></tr> <tr valign="top" class="even"><td ><a href="q3url.html#pathx">path</a>()</td><td >"/cgi-bin/test&nbsp;me.pl"</td></tr> <tr valign="top" class="odd"><td ><a href="q3url.html#fileName">fileName</a>()</td><td >"test&nbsp;me.pl"</td></tr> <tr valign="top" class="even"><td ><a href="q3url.html#query">query</a>()</td><td >"cmd=Hello%20you"</td></tr> </table> <p>Example:</p> <p><tt>http://qt.nokia.com/doc/qdockarea.html#lines</tt></p> <table class="generic"> <thead><tr class="qt-style"><th >Function</th><th >Returns</th></tr></thead> <tr valign="top" class="odd"><td ><a href="q3url.html#protocol">protocol</a>()</td><td >"http"</td></tr> <tr valign="top" class="even"><td ><a href="q3url.html#host">host</a>()</td><td >"qt.nokia.com"</td></tr> <tr valign="top" class="odd"><td ><a href="q3url.html#fileName">fileName</a>()</td><td >"doc/qdockarea.html"</td></tr> <tr valign="top" class="even"><td ><a href="q3url.html#ref">ref</a>()</td><td >"lines"</td></tr> </table> <p>The individual parts of a URL can be set with <a href="q3url.html#setProtocol">setProtocol</a>(), <a href="q3url.html#setHost">setHost</a>(), <a href="q3url.html#setPort">setPort</a>(), <a href="q3url.html#setPath">setPath</a>(), <a href="q3url.html#setFileName">setFileName</a>(), <a href="q3url.html#setRef">setRef</a>() and <a href="q3url.html#setQuery">setQuery</a>(). A URL could contain, for example, an ftp address which requires a user name and password; these can be set with <a href="q3url.html#setUser">setUser</a>() and <a href="q3url.html#setPassword">setPassword</a>().</p> <p>Because path is always encoded internally you must not use "%00" in the path, although this is okay (but not recommended) for the query.</p> <p>Q3Url is normally used like this:</p> <pre class="cpp"> <span class="type">Q3Url</span> url( <span class="string">"http://qt.nokia.com"</span> ); <span class="comment">// or</span> <span class="type">Q3Url</span> url( <span class="string">"file:///home/myself/Mail"</span><span class="operator">,</span> <span class="string">"Inbox"</span> );</pre> <p>You can then access and manipulate the various parts of the URL.</p> <p>To make it easy to work with Q3Urls and QStrings, Q3Url implements the necessary cast and assignment operators so you can do following:</p> <pre class="cpp"> <span class="type">Q3Url</span> url( <span class="string">"http://qt.nokia.com"</span> ); <span class="type"><a href="qstring.html">QString</a></span> s <span class="operator">=</span> url; <span class="comment">// or</span> <span class="type"><a href="qstring.html">QString</a></span> s( <span class="string">"http://qt.nokia.com"</span> ); <span class="type">Q3Url</span> url( s );</pre> <p>Use the static functions, <a href="q3url.html#encode">encode</a>() and <a href="q3url.html#decode">decode</a>() to encode or decode a URL in a string. (They operate on the string in-place.) The <a href="q3url.html#isRelativeUrl">isRelativeUrl</a>() static function returns true if the given string is a relative URL.</p> <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="q3urloperator.html">Q3UrlOperator</a>.</p> </div> <p><b>See also </b><a href="q3urloperator.html">Q3UrlOperator</a>.</p> <!-- @@@Q3Url --> <div class="func"> <h2>Member Function Documentation</h2> <!-- $$$Q3Url[overload1]$$$Q3Url --> <h3 class="fn"><a name="Q3Url"></a>Q3Url::<span class="name">Q3Url</span> ()</h3> <p>Constructs an empty URL that is invalid.</p> <!-- @@@Q3Url --> <!-- $$$Q3Url$$$Q3UrlconstQString& --> <h3 class="fn"><a name="Q3Url-2"></a>Q3Url::<span class="name">Q3Url</span> ( const <span class="type"><a href="qstring.html">QString</a></span> & <i>url</i> )</h3> <p>Constructs a URL by parsing the string <i>url</i>.</p> <p>If you pass a string like "/home/qt", the "file" protocol is assumed.</p> <!-- @@@Q3Url --> <!-- $$$Q3Url$$$Q3UrlconstQ3Url& --> <h3 class="fn"><a name="Q3Url-3"></a>Q3Url::<span class="name">Q3Url</span> ( const <span class="type">Q3Url</span> & <i>url</i> )</h3> <p>Copy constructor. Copies the data of <i>url</i>.</p> <!-- @@@Q3Url --> <!-- $$$Q3Url$$$Q3UrlconstQ3Url&constQString&bool --> <h3 class="fn"><a name="Q3Url-4"></a>Q3Url::<span class="name">Q3Url</span> ( const <span class="type">Q3Url</span> & <i>url</i>, const <span class="type"><a href="qstring.html">QString</a></span> & <i>relUrl</i>, <span class="type">bool</span> <i>checkSlash</i> = false )</h3> <p>Constructs an URL taking <i>url</i> as the base (context) and <i>relUrl</i> as a relative URL to <i>url</i>. If <i>relUrl</i> is not relative, <i>relUrl</i> is taken as the new URL.</p> <p>For example, the path of</p> <pre class="cpp"> <span class="type"><a href="q3url.html">Q3Url</a></span> url( <span class="string">"ftp://ftp.qt.nokia.com/qt/source"</span><span class="operator">,</span> <span class="string">"qt-2.1.0.tar.gz"</span> );</pre> <p>will be "/qt/srource/qt-2.1.0.tar.gz".</p> <p>On the other hand,</p> <pre class="cpp"> <span class="type"><a href="q3url.html">Q3Url</a></span> url( <span class="string">"ftp://ftp.qt.nokia.com/qt/source"</span><span class="operator">,</span> <span class="string">"/usr/local"</span> );</pre> <p>will result in a new URL, "ftp://ftp.qt.nokia.com/usr/local", because "/usr/local" isn't relative.</p> <p>Similarly,</p> <pre class="cpp"> <span class="type"><a href="q3url.html">Q3Url</a></span> url( <span class="string">"ftp://ftp.qt.nokia.com/qt/source"</span><span class="operator">,</span> <span class="string">"file:///usr/local"</span> );</pre> <p>will result in a new URL, with "/usr/local" as the path and "file" as the protocol.</p> <p>Normally it is expected that the path of <i>url</i> 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 <i>relUrl</i> (if it contains one), set <i>checkSlash</i> to true.</p> <!-- @@@Q3Url --> <!-- $$$~Q3Url[overload1]$$$~Q3Url --> <h3 class="fn"><a name="dtor.Q3Url"></a>Q3Url::<span class="name">~Q3Url</span> ()<tt> [virtual]</tt></h3> <p>Destructor.</p> <!-- @@@~Q3Url --> <!-- $$$addPath[overload1]$$$addPathconstQString& --> <h3 class="fn"><a name="addPath"></a><span class="type">void</span> Q3Url::<span class="name">addPath</span> ( const <span class="type"><a href="qstring.html">QString</a></span> & <i>pa</i> )<tt> [virtual]</tt></h3> <p>Adds the path <i>pa</i> to the path of the URL.</p> <p><b>See also </b><a href="q3url.html#setPath">setPath</a>() and <a href="q3url.html#hasPath">hasPath</a>().</p> <!-- @@@addPath --> <!-- $$$cdUp[overload1]$$$cdUp --> <h3 class="fn"><a name="cdUp"></a><span class="type">bool</span> Q3Url::<span class="name">cdUp</span> ()<tt> [virtual]</tt></h3> <p>Changes the directory to one directory up. This function always returns true.</p> <p><b>See also </b><a href="q3url.html#setPath">setPath</a>().</p> <!-- @@@cdUp --> <!-- $$$decode[overload1]$$$decodeQString& --> <h3 class="fn"><a name="decode"></a><span class="type">void</span> Q3Url::<span class="name">decode</span> ( <span class="type"><a href="qstring.html">QString</a></span> & <i>url</i> )<tt> [static]</tt></h3> <p>Decodes the <i>url</i> in-place into UTF-8. For example</p> <pre class="cpp"> <span class="type"><a href="qstring.html">QString</a></span> url <span class="operator">=</span> <span class="string">"http%3A//qt%20nokia%20com"</span> <span class="type"><a href="q3url.html">Q3Url</a></span><span class="operator">::</span>decode( url ); <span class="comment">// url is now "http://qt.nokia.com"</span></pre> <p><b>See also </b><a href="q3url.html#encode">encode</a>().</p> <!-- @@@decode --> <!-- $$$dirPath[overload1]$$$dirPath --> <h3 class="fn"><a name="dirPath"></a><span class="type"><a href="qstring.html">QString</a></span> Q3Url::<span class="name">dirPath</span> () const</h3> <p>Returns the directory path of the URL. This is the part of the path of the URL without the <a href="q3url.html#fileName">fileName</a>(). See the documentation of <a href="q3url.html#fileName">fileName</a>() for a discussion of what is handled as file name and what is handled as directory path.</p> <p><b>See also </b><a href="q3url.html#setPath">setPath</a>() and <a href="q3url.html#hasPath">hasPath</a>().</p> <!-- @@@dirPath --> <!-- $$$encode[overload1]$$$encodeQString& --> <h3 class="fn"><a name="encode"></a><span class="type">void</span> Q3Url::<span class="name">encode</span> ( <span class="type"><a href="qstring.html">QString</a></span> & <i>url</i> )<tt> [static]</tt></h3> <p>Encodes the <i>url</i> in-place into UTF-8. For example</p> <pre class="cpp"> <span class="type"><a href="qstring.html">QString</a></span> url <span class="operator">=</span> http:<span class="comment">//qt.nokia.com</span> <span class="type"><a href="q3url.html">Q3Url</a></span><span class="operator">::</span>encode( url ); <span class="comment">// url is now "http%3A//qt%20nokia%20com"</span></pre> <p><b>See also </b><a href="q3url.html#decode">decode</a>().</p> <!-- @@@encode --> <!-- $$$encodedPathAndQuery[overload1]$$$encodedPathAndQuery --> <h3 class="fn"><a name="encodedPathAndQuery"></a><span class="type"><a href="qstring.html">QString</a></span> Q3Url::<span class="name">encodedPathAndQuery</span> ()</h3> <p>Returns the encoded path and query.</p> <p><b>See also </b><a href="q3url.html#setEncodedPathAndQuery">setEncodedPathAndQuery</a>() and <a href="q3url.html#decode">decode</a>().</p> <!-- @@@encodedPathAndQuery --> <!-- $$$fileName[overload1]$$$fileName --> <h3 class="fn"><a name="fileName"></a><span class="type"><a href="qstring.html">QString</a></span> Q3Url::<span class="name">fileName</span> () const</h3> <p>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.</p> <p><b>See also </b><a href="q3url.html#setFileName">setFileName</a>().</p> <!-- @@@fileName --> <!-- $$$hasHost[overload1]$$$hasHost --> <h3 class="fn"><a name="hasHost"></a><span class="type">bool</span> Q3Url::<span class="name">hasHost</span> () const</h3> <p>Returns true if the URL contains a hostname; otherwise returns false.</p> <p><b>See also </b><a href="q3url.html#setHost">setHost</a>().</p> <!-- @@@hasHost --> <!-- $$$hasPassword[overload1]$$$hasPassword --> <h3 class="fn"><a name="hasPassword"></a><span class="type">bool</span> Q3Url::<span class="name">hasPassword</span> () const</h3> <p>Returns true if the URL contains a password; otherwise returns false.</p> <p><b>Warning:</b> Passwords passed in URLs are normally <i>insecure</i>; this is due to the mechanism, not because of Qt.</p> <p><b>See also </b><a href="q3url.html#setPassword">setPassword</a>() and <a href="q3url.html#setUser">setUser</a>().</p> <!-- @@@hasPassword --> <!-- $$$hasPath[overload1]$$$hasPath --> <h3 class="fn"><a name="hasPath"></a><span class="type">bool</span> Q3Url::<span class="name">hasPath</span> () const</h3> <p>Returns true if the URL contains a path; otherwise returns false.</p> <p><b>See also </b><a href="q3url.html#pathx">path</a>() and <a href="q3url.html#setPath">setPath</a>().</p> <!-- @@@hasPath --> <!-- $$$hasPort[overload1]$$$hasPort --> <h3 class="fn"><a name="hasPort"></a><span class="type">bool</span> Q3Url::<span class="name">hasPort</span> () const</h3> <p>Returns true if the URL contains a port; otherwise returns false.</p> <p><b>See also </b><a href="q3url.html#setPort">setPort</a>().</p> <!-- @@@hasPort --> <!-- $$$hasRef[overload1]$$$hasRef --> <h3 class="fn"><a name="hasRef"></a><span class="type">bool</span> Q3Url::<span class="name">hasRef</span> () const</h3> <p>Returns true if the URL has a reference; otherwise returns false.</p> <p><b>See also </b><a href="q3url.html#setRef">setRef</a>().</p> <!-- @@@hasRef --> <!-- $$$hasUser[overload1]$$$hasUser --> <h3 class="fn"><a name="hasUser"></a><span class="type">bool</span> Q3Url::<span class="name">hasUser</span> () const</h3> <p>Returns true if the URL contains a username; otherwise returns false.</p> <p><b>See also </b><a href="q3url.html#setUser">setUser</a>() and <a href="q3url.html#setPassword">setPassword</a>().</p> <!-- @@@hasUser --> <!-- $$$host[overload1]$$$host --> <h3 class="fn"><a name="host"></a><span class="type"><a href="qstring.html">QString</a></span> Q3Url::<span class="name">host</span> () const</h3> <p>Returns the hostname of the URL.</p> <p><b>See also </b><a href="q3url.html#setHost">setHost</a>() and <a href="q3url.html#hasHost">hasHost</a>().</p> <!-- @@@host --> <!-- $$$isLocalFile[overload1]$$$isLocalFile --> <h3 class="fn"><a name="isLocalFile"></a><span class="type">bool</span> Q3Url::<span class="name">isLocalFile</span> () const</h3> <p>Returns true if the URL is a local file; otherwise returns false.</p> <!-- @@@isLocalFile --> <!-- $$$isRelativeUrl[overload1]$$$isRelativeUrlconstQString& --> <h3 class="fn"><a name="isRelativeUrl"></a><span class="type">bool</span> Q3Url::<span class="name">isRelativeUrl</span> ( const <span class="type"><a href="qstring.html">QString</a></span> & <i>url</i> )<tt> [static]</tt></h3> <p>Returns true if <i>url</i> is relative; otherwise returns false.</p> <!-- @@@isRelativeUrl --> <!-- $$$isValid[overload1]$$$isValid --> <h3 class="fn"><a name="isValid"></a><span class="type">bool</span> Q3Url::<span class="name">isValid</span> () const</h3> <p>Returns true if the URL is valid; otherwise returns false. A URL is invalid if it cannot be parsed, for example.</p> <!-- @@@isValid --> <!-- $$$parse[overload1]$$$parseconstQString& --> <h3 class="fn"><a name="parse"></a><span class="type">bool</span> Q3Url::<span class="name">parse</span> ( const <span class="type"><a href="qstring.html">QString</a></span> & <i>url</i> )<tt> [virtual protected]</tt></h3> <p>Parses the <i>url</i>. Returns true on success; otherwise returns false.</p> <!-- @@@parse --> <!-- $$$password[overload1]$$$password --> <h3 class="fn"><a name="password"></a><span class="type"><a href="qstring.html">QString</a></span> Q3Url::<span class="name">password</span> () const</h3> <p>Returns the password of the URL.</p> <p><b>Warning:</b> Passwords passed in URLs are normally <i>insecure</i>; this is due to the mechanism, not because of Qt.</p> <p><b>See also </b><a href="q3url.html#setPassword">setPassword</a>() and <a href="q3url.html#setUser">setUser</a>().</p> <!-- @@@password --> <!-- $$$path[overload1]$$$pathbool --> <h3 class="fn"><a name="pathx"></a><span class="type"><a href="qstring.html">QString</a></span> Q3Url::<span class="name">path</span> ( <span class="type">bool</span> <i>correct</i> = true ) const</h3> <p>Returns the path of the URL. If <i>correct</i> 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.</p> <p><b>See also </b><a href="q3url.html#setPath">setPath</a>() and <a href="q3url.html#hasPath">hasPath</a>().</p> <!-- @@@path --> <!-- $$$port[overload1]$$$port --> <h3 class="fn"><a name="port"></a><span class="type">int</span> Q3Url::<span class="name">port</span> () const</h3> <p>Returns the port of the URL or -1 if no port has been set.</p> <p><b>See also </b><a href="q3url.html#setPort">setPort</a>().</p> <!-- @@@port --> <!-- $$$protocol[overload1]$$$protocol --> <h3 class="fn"><a name="protocol"></a><span class="type"><a href="qstring.html">QString</a></span> Q3Url::<span class="name">protocol</span> () const</h3> <p>Returns the protocol of the URL. Typically, "file", "http", "ftp", etc.</p> <p><b>See also </b><a href="q3url.html#setProtocol">setProtocol</a>().</p> <!-- @@@protocol --> <!-- $$$query[overload1]$$$query --> <h3 class="fn"><a name="query"></a><span class="type"><a href="qstring.html">QString</a></span> Q3Url::<span class="name">query</span> () const</h3> <p>Returns the (encoded) query of the URL.</p> <p><b>See also </b><a href="q3url.html#setQuery">setQuery</a>() and <a href="q3url.html#decode">decode</a>().</p> <!-- @@@query --> <!-- $$$ref[overload1]$$$ref --> <h3 class="fn"><a name="ref"></a><span class="type"><a href="qstring.html">QString</a></span> Q3Url::<span class="name">ref</span> () const</h3> <p>Returns the (encoded) reference of the URL.</p> <p><b>See also </b><a href="q3url.html#setRef">setRef</a>(), <a href="q3url.html#hasRef">hasRef</a>(), and <a href="q3url.html#decode">decode</a>().</p> <!-- @@@ref --> <!-- $$$reset[overload1]$$$reset --> <h3 class="fn"><a name="reset"></a><span class="type">void</span> Q3Url::<span class="name">reset</span> ()<tt> [virtual protected]</tt></h3> <p>Resets all parts of the URL to their default values and invalidates it.</p> <!-- @@@reset --> <!-- $$$setEncodedPathAndQuery[overload1]$$$setEncodedPathAndQueryconstQString& --> <h3 class="fn"><a name="setEncodedPathAndQuery"></a><span class="type">void</span> Q3Url::<span class="name">setEncodedPathAndQuery</span> ( const <span class="type"><a href="qstring.html">QString</a></span> & <i>pathAndQuery</i> )<tt> [virtual]</tt></h3> <p>Parses <i>pathAndQuery</i> for a path and query and sets those values. The whole string must be encoded.</p> <p><b>See also </b><a href="q3url.html#encodedPathAndQuery">encodedPathAndQuery</a>() and <a href="q3url.html#encode">encode</a>().</p> <!-- @@@setEncodedPathAndQuery --> <!-- $$$setFileName[overload1]$$$setFileNameconstQString& --> <h3 class="fn"><a name="setFileName"></a><span class="type">void</span> Q3Url::<span class="name">setFileName</span> ( const <span class="type"><a href="qstring.html">QString</a></span> & <i>name</i> )<tt> [virtual]</tt></h3> <p>Sets the file name of the URL to <i>name</i>. If this URL contains a <a href="q3url.html#fileName">fileName</a>(), the original file name is replaced by <i>name</i>.</p> <p>See the documentation of <a href="q3url.html#fileName">fileName</a>() for a more detailed discussion of what is handled as file name and what is handled as a directory path.</p> <p><b>See also </b><a href="q3url.html#fileName">fileName</a>().</p> <!-- @@@setFileName --> <!-- $$$setHost[overload1]$$$setHostconstQString& --> <h3 class="fn"><a name="setHost"></a><span class="type">void</span> Q3Url::<span class="name">setHost</span> ( const <span class="type"><a href="qstring.html">QString</a></span> & <i>host</i> )<tt> [virtual]</tt></h3> <p>Sets the hostname of the URL to <i>host</i>.</p> <p><b>See also </b><a href="q3url.html#host">host</a>() and <a href="q3url.html#hasHost">hasHost</a>().</p> <!-- @@@setHost --> <!-- $$$setPassword[overload1]$$$setPasswordconstQString& --> <h3 class="fn"><a name="setPassword"></a><span class="type">void</span> Q3Url::<span class="name">setPassword</span> ( const <span class="type"><a href="qstring.html">QString</a></span> & <i>pass</i> )<tt> [virtual]</tt></h3> <p>Sets the password of the URL to <i>pass</i>.</p> <p><b>Warning:</b> Passwords passed in URLs are normally <i>insecure</i>; this is due to the mechanism, not because of Qt.</p> <p><b>See also </b><a href="q3url.html#password">password</a>() and <a href="q3url.html#setUser">setUser</a>().</p> <!-- @@@setPassword --> <!-- $$$setPath[overload1]$$$setPathconstQString& --> <h3 class="fn"><a name="setPath"></a><span class="type">void</span> Q3Url::<span class="name">setPath</span> ( const <span class="type"><a href="qstring.html">QString</a></span> & <i>path</i> )<tt> [virtual]</tt></h3> <p>Sets the path of the URL to <i>path</i>.</p> <p><b>See also </b><a href="q3url.html#pathx">path</a>() and <a href="q3url.html#hasPath">hasPath</a>().</p> <!-- @@@setPath --> <!-- $$$setPort[overload1]$$$setPortint --> <h3 class="fn"><a name="setPort"></a><span class="type">void</span> Q3Url::<span class="name">setPort</span> ( <span class="type">int</span> <i>port</i> )<tt> [virtual]</tt></h3> <p>Sets the port of the URL to <i>port</i>.</p> <p><b>See also </b><a href="q3url.html#port">port</a>().</p> <!-- @@@setPort --> <!-- $$$setProtocol[overload1]$$$setProtocolconstQString& --> <h3 class="fn"><a name="setProtocol"></a><span class="type">void</span> Q3Url::<span class="name">setProtocol</span> ( const <span class="type"><a href="qstring.html">QString</a></span> & <i>protocol</i> )<tt> [virtual]</tt></h3> <p>Sets the protocol of the URL to <i>protocol</i>. Typically, "file", "http", "ftp", etc.</p> <p><b>See also </b><a href="q3url.html#protocol">protocol</a>().</p> <!-- @@@setProtocol --> <!-- $$$setQuery[overload1]$$$setQueryconstQString& --> <h3 class="fn"><a name="setQuery"></a><span class="type">void</span> Q3Url::<span class="name">setQuery</span> ( const <span class="type"><a href="qstring.html">QString</a></span> & <i>txt</i> )<tt> [virtual]</tt></h3> <p>Sets the query of the URL to <i>txt</i>. <i>txt</i> must be encoded.</p> <p><b>See also </b><a href="q3url.html#query">query</a>() and <a href="q3url.html#encode">encode</a>().</p> <!-- @@@setQuery --> <!-- $$$setRef[overload1]$$$setRefconstQString& --> <h3 class="fn"><a name="setRef"></a><span class="type">void</span> Q3Url::<span class="name">setRef</span> ( const <span class="type"><a href="qstring.html">QString</a></span> & <i>txt</i> )<tt> [virtual]</tt></h3> <p>Sets the reference of the URL to <i>txt</i>. <i>txt</i> must be encoded.</p> <p><b>See also </b><a href="q3url.html#ref">ref</a>(), <a href="q3url.html#hasRef">hasRef</a>(), and <a href="q3url.html#encode">encode</a>().</p> <!-- @@@setRef --> <!-- $$$setUser[overload1]$$$setUserconstQString& --> <h3 class="fn"><a name="setUser"></a><span class="type">void</span> Q3Url::<span class="name">setUser</span> ( const <span class="type"><a href="qstring.html">QString</a></span> & <i>user</i> )<tt> [virtual]</tt></h3> <p>Sets the username of the URL to <i>user</i>.</p> <p><b>See also </b><a href="q3url.html#user">user</a>() and <a href="q3url.html#setPassword">setPassword</a>().</p> <!-- @@@setUser --> <!-- $$$toString[overload1]$$$toStringboolbool --> <h3 class="fn"><a name="toString"></a><span class="type"><a href="qstring.html">QString</a></span> Q3Url::<span class="name">toString</span> ( <span class="type">bool</span> <i>encodedPath</i> = false, <span class="type">bool</span> <i>forcePrependProtocol</i> = true ) const<tt> [virtual]</tt></h3> <p>Composes a string version of the URL and returns it. If <i>encodedPath</i> is true the path in the returned string is encoded. If <i>forcePrependProtocol</i> is true and <i>encodedPath</i> looks like a local filename, the "file:/" protocol is also prepended.</p> <p><b>See also </b><a href="q3url.html#encode">encode</a>() and <a href="q3url.html#decode">decode</a>().</p> <!-- @@@toString --> <!-- $$$user[overload1]$$$user --> <h3 class="fn"><a name="user"></a><span class="type"><a href="qstring.html">QString</a></span> Q3Url::<span class="name">user</span> () const</h3> <p>Returns the username of the URL.</p> <p><b>See also </b><a href="q3url.html#setUser">setUser</a>() and <a href="q3url.html#setPassword">setPassword</a>().</p> <!-- @@@user --> <!-- $$$operator QString[overload1]$$$operator QString --> <h3 class="fn"><a name="operator-QString"></a>Q3Url::<span class="name">operator QString</span> () const</h3> <p>Composes a string version of the URL and returns it.</p> <p><b>See also </b><a href="q3url.html#toString">Q3Url::toString</a>().</p> <!-- @@@operator QString --> <!-- $$$operator=[overload1]$$$operator=constQ3Url& --> <h3 class="fn"><a name="operator-eq"></a><span class="type">Q3Url</span> & Q3Url::<span class="name">operator=</span> ( const <span class="type">Q3Url</span> & <i>url</i> )</h3> <p>Assigns the data of <i>url</i> to this class.</p> <!-- @@@operator= --> <!-- $$$operator=$$$operator=constQString& --> <h3 class="fn"><a name="operator-eq-2"></a><span class="type">Q3Url</span> & Q3Url::<span class="name">operator=</span> ( const <span class="type"><a href="qstring.html">QString</a></span> & <i>url</i> )</h3> <p>This is an overloaded function.</p> <p>Parses <i>url</i> and assigns the resulting data to this class.</p> <p>If you pass a string like "/home/qt" the "file" protocol will be assumed.</p> <!-- @@@operator= --> <!-- $$$operator==[overload1]$$$operator==constQ3Url& --> <h3 class="fn"><a name="operator-eq-eq"></a><span class="type">bool</span> Q3Url::<span class="name">operator==</span> ( const <span class="type">Q3Url</span> & <i>url</i> ) const</h3> <p>Compares this URL with <i>url</i> and returns true if they are equal; otherwise returns false.</p> <!-- @@@operator== --> <!-- $$$operator==$$$operator==constQString& --> <h3 class="fn"><a name="operator-eq-eq-2"></a><span class="type">bool</span> Q3Url::<span class="name">operator==</span> ( const <span class="type"><a href="qstring.html">QString</a></span> & <i>url</i> ) const</h3> <p>This is an overloaded function.</p> <p>Compares this URL with <i>url</i>. <i>url</i> is parsed first. Returns true if <i>url</i> is equal to this url; otherwise returns false.</p> <!-- @@@operator== --> </div> </div> </div> </div> <div class="ft"> <span></span> </div> </div> <div class="footer"> <p> <acronym title="Copyright">©</acronym> 2013 Digia Plc and/or its subsidiaries. Documentation contributions included herein are the copyrights of their respective owners.</p> <br /> <p> The documentation provided herein is licensed under the terms of the <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation License version 1.3</a> as published by the Free Software Foundation.</p> <p> Documentation sources may be obtained from <a href="http://www.qt-project.org"> www.qt-project.org</a>.</p> <br /> <p> Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide. All other trademarks are property of their respective owners. <a title="Privacy Policy" href="http://en.gitorious.org/privacy_policy/">Privacy Policy</a></p> </div> <script src="scripts/functions.js" type="text/javascript"></script> </body> </html>