Sophie

Sophie

distrib > Mageia > 7 > armv7hl > media > core-updates > by-pkgid > d5e62c01ae8d1e579463c6a871dd44bf > files > 937

qtbase5-doc-5.12.6-2.mga7.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qurl.cpp -->
  <title>QUrl Class | Qt Core 5.12.6</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td >Qt 5.12</td><td ><a href="qtcore-index.html">Qt Core</a></td><td ><a href="qtcore-module.html">C++ Classes</a></td><td >QUrl</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtcore-index.html">Qt 5.12.6 Reference Documentation</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#public-types">Public Types</a></li>
<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="#related-non-members">Related Non-Members</a></li>
<li class="level1"><a href="#macros">Macros</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
<li class="level2"><a href="#relative-urls-vs-relative-paths">Relative URLs vs Relative Paths</a></li>
<li class="level2"><a href="#error-checking">Error checking</a></li>
<li class="level2"><a href="#character-conversions">Character Conversions</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">QUrl Class</h1>
<!-- $$$QUrl-brief -->
<p>The <a href="qurl.html">QUrl</a> class provides a convenient interface for working with URLs. <a href="#details">More...</a></p>
<!-- @@@QUrl -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign">   <span class="preprocessor">#include &lt;QUrl&gt;</span>
</td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += core</td></tr></table></div><ul>
<li><a href="qurl-members.html">List of all members, including inherited members</a></li>
<li><a href="qurl-obsolete.html">Obsolete members</a></li>
</ul>
<p><b>Note:</b> All functions in this class are reentrant.</p>
<a name="public-types"></a>
<h2 id="public-types">Public Types</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#ComponentFormattingOption-enum">ComponentFormattingOption</a></b> { PrettyDecoded, EncodeSpaces, EncodeUnicode, EncodeDelimiters, ..., FullyDecoded }</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> flags </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#ComponentFormattingOption-enum">ComponentFormattingOptions</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> flags </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#UrlFormattingOption-enum">FormattingOptions</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#ParsingMode-enum">ParsingMode</a></b> { TolerantMode, StrictMode, DecodedMode }</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#UrlFormattingOption-enum">UrlFormattingOption</a></b> { None, RemoveScheme, RemovePassword, RemoveUserInfo, ..., NormalizePathSegments }</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#UserInputResolutionOption-enum">UserInputResolutionOption</a></b> { DefaultResolution, AssumeLocalFile }</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> flags </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#UserInputResolutionOption-enum">UserInputResolutionOptions</a></b></td></tr>
</table></div>
<a name="public-functions"></a>
<h2 id="public-functions">Public Functions</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#QUrl">QUrl</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#QUrl-1">QUrl</a></b>(const QUrl &amp;<i>other</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#QUrl-2">QUrl</a></b>(const QString &amp;<i>url</i>, QUrl::ParsingMode <i>parsingMode</i> = TolerantMode)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#QUrl-3">QUrl</a></b>(QUrl &amp;&amp;<i>other</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#dtor.QUrl">~QUrl</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QUrl </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#adjusted">adjusted</a></b>(QUrl::FormattingOptions <i>options</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#authority">authority</a></b>(QUrl::ComponentFormattingOptions <i>options</i> = PrettyDecoded) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#clear">clear</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#errorString">errorString</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#fileName">fileName</a></b>(QUrl::ComponentFormattingOptions <i>options</i> = FullyDecoded) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#fragment">fragment</a></b>(QUrl::ComponentFormattingOptions <i>options</i> = PrettyDecoded) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#hasFragment">hasFragment</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#hasQuery">hasQuery</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#host">host</a></b>(QUrl::ComponentFormattingOptions <i>options</i> = FullyDecoded) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#isEmpty">isEmpty</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#isLocalFile">isLocalFile</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#isParentOf">isParentOf</a></b>(const QUrl &amp;<i>childUrl</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#isRelative">isRelative</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#isValid">isValid</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#matches">matches</a></b>(const QUrl &amp;<i>url</i>, QUrl::FormattingOptions <i>options</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#password">password</a></b>(QUrl::ComponentFormattingOptions <i>options</i> = FullyDecoded) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#path">path</a></b>(QUrl::ComponentFormattingOptions <i>options</i> = FullyDecoded) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#port">port</a></b>(int <i>defaultPort</i> = -1) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#query">query</a></b>(QUrl::ComponentFormattingOptions <i>options</i> = PrettyDecoded) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QUrl </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#resolved">resolved</a></b>(const QUrl &amp;<i>relative</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#scheme">scheme</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#setAuthority">setAuthority</a></b>(const QString &amp;<i>authority</i>, QUrl::ParsingMode <i>mode</i> = TolerantMode)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#setFragment">setFragment</a></b>(const QString &amp;<i>fragment</i>, QUrl::ParsingMode <i>mode</i> = TolerantMode)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#setHost">setHost</a></b>(const QString &amp;<i>host</i>, QUrl::ParsingMode <i>mode</i> = DecodedMode)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#setPassword">setPassword</a></b>(const QString &amp;<i>password</i>, QUrl::ParsingMode <i>mode</i> = DecodedMode)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#setPath">setPath</a></b>(const QString &amp;<i>path</i>, QUrl::ParsingMode <i>mode</i> = DecodedMode)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#setPort">setPort</a></b>(int <i>port</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#setQuery">setQuery</a></b>(const QString &amp;<i>query</i>, QUrl::ParsingMode <i>mode</i> = TolerantMode)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#setQuery-1">setQuery</a></b>(const QUrlQuery &amp;<i>query</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#setScheme">setScheme</a></b>(const QString &amp;<i>scheme</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#setUrl">setUrl</a></b>(const QString &amp;<i>url</i>, QUrl::ParsingMode <i>parsingMode</i> = TolerantMode)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#setUserInfo">setUserInfo</a></b>(const QString &amp;<i>userInfo</i>, QUrl::ParsingMode <i>mode</i> = TolerantMode)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#setUserName">setUserName</a></b>(const QString &amp;<i>userName</i>, QUrl::ParsingMode <i>mode</i> = DecodedMode)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#swap">swap</a></b>(QUrl &amp;<i>other</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> CFURLRef </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#toCFURL">toCFURL</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#toDisplayString">toDisplayString</a></b>(QUrl::FormattingOptions <i>options</i> = FormattingOptions(PrettyDecoded)) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QByteArray </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#toEncoded">toEncoded</a></b>(QUrl::FormattingOptions <i>options</i> = FullyEncoded) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#toLocalFile">toLocalFile</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> NSURL *</td><td class="memItemRight bottomAlign"><b><a href="qurl.html#toNSURL">toNSURL</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#toString">toString</a></b>(QUrl::FormattingOptions <i>options</i> = FormattingOptions(PrettyDecoded)) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#topLevelDomain">topLevelDomain</a></b>(QUrl::ComponentFormattingOptions <i>options</i> = FullyDecoded) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#url">url</a></b>(QUrl::FormattingOptions <i>options</i> = FormattingOptions(PrettyDecoded)) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#userInfo">userInfo</a></b>(QUrl::ComponentFormattingOptions <i>options</i> = PrettyDecoded) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#userName">userName</a></b>(QUrl::ComponentFormattingOptions <i>options</i> = FullyDecoded) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#operator-not-eq">operator!=</a></b>(const QUrl &amp;<i>url</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QUrl &amp;</td><td class="memItemRight bottomAlign"><b><a href="qurl.html#operator-eq">operator=</a></b>(const QUrl &amp;<i>url</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QUrl &amp;</td><td class="memItemRight bottomAlign"><b><a href="qurl.html#operator-eq-1">operator=</a></b>(const QString &amp;<i>url</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QUrl &amp;</td><td class="memItemRight bottomAlign"><b><a href="qurl.html#operator-eq-2">operator=</a></b>(QUrl &amp;&amp;<i>other</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#operator-eq-eq">operator==</a></b>(const QUrl &amp;<i>url</i>) const</td></tr>
</table></div>
<a name="static-public-members"></a>
<h2 id="static-public-members">Static Public Members</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#fromAce">fromAce</a></b>(const QByteArray &amp;<i>domain</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QUrl </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#fromCFURL">fromCFURL</a></b>(CFURLRef <i>url</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QUrl </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#fromEncoded">fromEncoded</a></b>(const QByteArray &amp;<i>input</i>, QUrl::ParsingMode <i>parsingMode</i> = TolerantMode)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QUrl </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#fromLocalFile">fromLocalFile</a></b>(const QString &amp;<i>localFile</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QUrl </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#fromNSURL">fromNSURL</a></b>(const NSURL *<i>url</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#fromPercentEncoding">fromPercentEncoding</a></b>(const QByteArray &amp;<i>input</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QList&lt;QUrl&gt; </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#fromStringList">fromStringList</a></b>(const QStringList &amp;<i>urls</i>, QUrl::ParsingMode <i>mode</i> = TolerantMode)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QUrl </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#fromUserInput">fromUserInput</a></b>(const QString &amp;<i>userInput</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QUrl </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#fromUserInput-1">fromUserInput</a></b>(const QString &amp;<i>userInput</i>, const QString &amp;<i>workingDirectory</i>, QUrl::UserInputResolutionOptions <i>options</i> = DefaultResolution)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QStringList </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#idnWhitelist">idnWhitelist</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#setIdnWhitelist">setIdnWhitelist</a></b>(const QStringList &amp;<i>list</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QByteArray </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#toAce">toAce</a></b>(const QString &amp;<i>domain</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QByteArray </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#toPercentEncoding">toPercentEncoding</a></b>(const QString &amp;<i>input</i>, const QByteArray &amp;<i>exclude</i> = QByteArray(), const QByteArray &amp;<i>include</i> = QByteArray())</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QStringList </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#toStringList">toStringList</a></b>(const QList&lt;QUrl&gt; &amp;<i>urls</i>, QUrl::FormattingOptions <i>options</i> = FormattingOptions(PrettyDecoded))</td></tr>
</table></div>
<a name="related-non-members"></a>
<h2 id="related-non-members">Related Non-Members</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> QDataStream &amp;</td><td class="memItemRight bottomAlign"><b><a href="qurl.html#operator-lt-lt">operator&lt;&lt;</a></b>(QDataStream &amp;<i>out</i>, const QUrl &amp;<i>url</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QDataStream &amp;</td><td class="memItemRight bottomAlign"><b><a href="qurl.html#operator-gt-gt">operator&gt;&gt;</a></b>(QDataStream &amp;<i>in</i>, QUrl &amp;<i>url</i>)</td></tr>
</table></div>
<a name="macros"></a>
<h2 id="macros">Macros</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qurl.html#QT_NO_URL_CAST_FROM_STRING">QT_NO_URL_CAST_FROM_STRING</a></b></td></tr>
</table></div>
<a name="details"></a>
<!-- $$$QUrl-description -->
<div class="descr">
<h2 id="details">Detailed Description</h2>
<p>The <a href="qurl.html">QUrl</a> class provides a convenient interface for working with URLs.</p>
<p>It can parse and construct URLs in both encoded and unencoded form. <a href="qurl.html">QUrl</a> also has support for internationalized domain names (IDNs).</p>
<p>The most common way to use <a href="qurl.html">QUrl</a> is to initialize it via the constructor by passing a <a href="qstring.html">QString</a>. Otherwise, <a href="qurl.html#setUrl">setUrl</a>() can also be used.</p>
<p>URLs can be represented in two forms: encoded or unencoded. The unencoded representation is suitable for showing to users, but the encoded representation is typically what you would send to a web server. For example, the unencoded URL &quot;http://bühler.example.com/List of applicants.xml&quot; would be sent to the server as &quot;http://xn--bhler-kva.example.com/List%20of%20applicants.xml&quot;.</p>
<p>A URL can also be constructed piece by piece by calling <a href="qurl.html#setScheme">setScheme</a>(), <a href="qurl.html#setUserName">setUserName</a>(), <a href="qurl.html#setPassword">setPassword</a>(), <a href="qurl.html#setHost">setHost</a>(), <a href="qurl.html#setPort">setPort</a>(), <a href="qurl.html#setPath">setPath</a>(), <a href="qurl.html#setQuery">setQuery</a>() and <a href="qurl.html#setFragment">setFragment</a>(). Some convenience functions are also available: <a href="qurl.html#setAuthority">setAuthority</a>() sets the user name, password, host and port. <a href="qurl.html#setUserInfo">setUserInfo</a>() sets the user name and password at once.</p>
<p>Call <a href="qurl.html#isValid">isValid</a>() to check if the URL is valid. This can be done at any point during the constructing of a URL. If <a href="qurl.html#isValid">isValid</a>() returns <code>false</code>, you should <a href="qurl.html#clear">clear</a>() the URL before proceeding, or start over by parsing a new URL with <a href="qurl.html#setUrl">setUrl</a>().</p>
<p>Constructing a query is particularly convenient through the use of the <a href="qurlquery.html">QUrlQuery</a> class and its methods <a href="qurlquery.html#setQueryItems">QUrlQuery::setQueryItems</a>(), <a href="qurlquery.html#addQueryItem">QUrlQuery::addQueryItem</a>() and <a href="qurlquery.html#removeQueryItem">QUrlQuery::removeQueryItem</a>(). Use <a href="qurlquery.html#setQueryDelimiters">QUrlQuery::setQueryDelimiters</a>() to customize the delimiters used for generating the query string.</p>
<p>For the convenience of generating encoded URL strings or query strings, there are two static functions called <a href="qurl.html#fromPercentEncoding">fromPercentEncoding</a>() and <a href="qurl.html#toPercentEncoding">toPercentEncoding</a>() which deal with percent encoding and decoding of <a href="qstring.html">QString</a> objects.</p>
<p><a href="qurl.html#fromLocalFile">fromLocalFile</a>() constructs a <a href="qurl.html">QUrl</a> by parsing a local file path. <a href="qurl.html#toLocalFile">toLocalFile</a>() converts a URL to a local file path.</p>
<p>The human readable representation of the URL is fetched with <a href="qurl.html#toString">toString</a>(). This representation is appropriate for displaying a URL to a user in unencoded form. The encoded form however, as returned by <a href="qurl.html#toEncoded">toEncoded</a>(), is for internal use, passing to web servers, mail clients and so on. Both forms are technically correct and represent the same URL unambiguously -- in fact, passing either form to <a href="qurl.html">QUrl</a>'s constructor or to <a href="qurl.html#setUrl">setUrl</a>() will yield the same <a href="qurl.html">QUrl</a> object.</p>
<p><a href="qurl.html">QUrl</a> conforms to the URI specification from RFC 3986 (Uniform Resource Identifier: Generic Syntax), and includes scheme extensions from RFC 1738 (Uniform Resource Locators). Case folding rules in <a href="qurl.html">QUrl</a> conform to RFC 3491 (Nameprep: A Stringprep Profile for Internationalized Domain Names (IDN)). It is also compatible with the <a href="http://freedesktop.org/wiki/Specifications/file-uri-spec/">file URI specification</a> from freedesktop.org, provided that the locale encodes file names using UTF-8 (required by IDN).</p>
<a name="relative-urls-vs-relative-paths"></a>
<h4 id="relative-urls-vs-relative-paths">Relative URLs vs Relative Paths</h4>
<p>Calling <a href="qurl.html#isRelative">isRelative</a>() will return whether or not the URL is relative. A relative URL has no <a href="qurl.html#scheme">scheme</a>. For example:</p>
<pre class="cpp">

      <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="type"><a href="qurl.html#QUrl">QUrl</a></span>(<span class="string">&quot;main.qml&quot;</span>)<span class="operator">.</span>isRelative();          <span class="comment">// true: no scheme</span>
      <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="type"><a href="qurl.html#QUrl">QUrl</a></span>(<span class="string">&quot;qml/main.qml&quot;</span>)<span class="operator">.</span>isRelative();      <span class="comment">// true: no scheme</span>
      <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="type"><a href="qurl.html#QUrl">QUrl</a></span>(<span class="string">&quot;file:main.qml&quot;</span>)<span class="operator">.</span>isRelative();     <span class="comment">// false: has &quot;file&quot; scheme</span>
      <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="type"><a href="qurl.html#QUrl">QUrl</a></span>(<span class="string">&quot;file:qml/main.qml&quot;</span>)<span class="operator">.</span>isRelative(); <span class="comment">// false: has &quot;file&quot; scheme</span>

</pre>
<p>Notice that a URL can be absolute while containing a relative path, and vice versa:</p>
<pre class="cpp">

      <span class="comment">// Absolute URL, relative path</span>
      <span class="type"><a href="qurl.html#QUrl">QUrl</a></span> url(<span class="string">&quot;file:file.txt&quot;</span>);
      <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> url<span class="operator">.</span>isRelative();                 <span class="comment">// false: has &quot;file&quot; scheme</span>
      <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="type"><a href="qdir.html">QDir</a></span><span class="operator">::</span>isAbsolutePath(url<span class="operator">.</span>path()); <span class="comment">// false: relative path</span>

      <span class="comment">// Relative URL, absolute path</span>
      url <span class="operator">=</span> <span class="type"><a href="qurl.html#QUrl">QUrl</a></span>(<span class="string">&quot;/home/user/file.txt&quot;</span>);
      <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> url<span class="operator">.</span>isRelative();                 <span class="comment">// true: has no scheme</span>
      <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="type"><a href="qdir.html">QDir</a></span><span class="operator">::</span>isAbsolutePath(url<span class="operator">.</span>path()); <span class="comment">// true: absolute path</span>

</pre>
<p>A relative URL can be resolved by passing it as an argument to <a href="qurl.html#resolved">resolved</a>(), which returns an absolute URL. <a href="qurl.html#isParentOf">isParentOf</a>() is used for determining whether one URL is a parent of another.</p>
<a name="error-checking"></a>
<h4 id="error-checking">Error checking</h4>
<p><a href="qurl.html">QUrl</a> is capable of detecting many errors in URLs while parsing it or when components of the URL are set with individual setter methods (like <a href="qurl.html#setScheme">setScheme</a>(), <a href="qurl.html#setHost">setHost</a>() or <a href="qurl.html#setPath">setPath</a>()). If the parsing or setter function is successful, any previously recorded error conditions will be discarded.</p>
<p>By default, <a href="qurl.html">QUrl</a> setter methods operate in <a href="qurl.html#ParsingMode-enum">QUrl::TolerantMode</a>, which means they accept some common mistakes and mis-representation of data. An alternate method of parsing is <a href="qurl.html#ParsingMode-enum">QUrl::StrictMode</a>, which applies further checks. See <a href="qurl.html#ParsingMode-enum">QUrl::ParsingMode</a> for a description of the difference of the parsing modes.</p>
<p><a href="qurl.html">QUrl</a> only checks for conformance with the URL specification. It does not try to verify that high-level protocol URLs are in the format they are expected to be by handlers elsewhere. For example, the following URIs are all considered valid by <a href="qurl.html">QUrl</a>, even if they do not make sense when used:</p>
<ul>
<li>&quot;http:/filename.html&quot;</li>
<li>&quot;mailto://example.com&quot;</li>
</ul>
<p>When the parser encounters an error, it signals the event by making <a href="qurl.html#isValid">isValid</a>() return false and <a href="qurl.html#toString">toString</a>() / <a href="qurl.html#toEncoded">toEncoded</a>() return an empty string. If it is necessary to show the user the reason why the URL failed to parse, the error condition can be obtained from <a href="qurl.html">QUrl</a> by calling <a href="qurl.html#errorString">errorString</a>(). Note that this message is highly technical and may not make sense to end-users.</p>
<p><a href="qurl.html">QUrl</a> is capable of recording only one error condition. If more than one error is found, it is undefined which error is reported.</p>
<a name="character-conversions"></a>
<h4 id="character-conversions">Character Conversions</h4>
<p>Follow these rules to avoid erroneous character conversion when dealing with URLs and strings:</p>
<ul>
<li>When creating a <a href="qstring.html">QString</a> to contain a URL from a <a href="qbytearray.html">QByteArray</a> or a char*, always use <a href="qstring.html#fromUtf8">QString::fromUtf8</a>().</li>
</ul>
</div>
<!-- @@@QUrl -->
<div class="types">
<h2>Member Type Documentation</h2>
<!-- $$$ComponentFormattingOption$$$PrettyDecoded$$$EncodeSpaces$$$EncodeUnicode$$$EncodeDelimiters$$$EncodeReserved$$$DecodeReserved$$$FullyEncoded$$$FullyDecoded -->
<h3 class="flags" id="ComponentFormattingOption-enum"><a name="ComponentFormattingOption-enum"></a>enum QUrl::<span class="name">ComponentFormattingOption</span><br/>flags QUrl::<span class="name">ComponentFormattingOptions</span></h3>
<p>The component formatting options define how the components of an URL will be formatted when written out as text. They can be combined with the options from <a href="qurl.html#UrlFormattingOption-enum">QUrl::FormattingOptions</a> when used in <a href="qurl.html#toString">toString</a>() and <a href="qurl.html#toEncoded">toEncoded</a>().</p>
<div class="table"><table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><code>QUrl::PrettyDecoded</code></td><td class="topAlign tblval"><code>0x000000</code></td><td class="topAlign">The component is returned in a &quot;pretty form&quot;, with most percent-encoded characters decoded. The exact behavior of PrettyDecoded varies from component to component and may also change from Qt release to Qt release. This is the default.</td></tr>
<tr><td class="topAlign"><code>QUrl::EncodeSpaces</code></td><td class="topAlign tblval"><code>0x100000</code></td><td class="topAlign">Leave space characters in their encoded form (&quot;%20&quot;).</td></tr>
<tr><td class="topAlign"><code>QUrl::EncodeUnicode</code></td><td class="topAlign tblval"><code>0x200000</code></td><td class="topAlign">Leave non-US-ASCII characters encoded in their UTF-8 percent-encoded form (e.g&#x2e;, &quot;%C3%A9&quot; for the U+00E9 codepoint, LATIN SMALL LETTER E WITH ACUTE).</td></tr>
<tr><td class="topAlign"><code>QUrl::EncodeDelimiters</code></td><td class="topAlign tblval"><code>0x400000 | 0x800000</code></td><td class="topAlign">Leave certain delimiters in their encoded form, as would appear in the URL when the full URL is represented as text. The delimiters are affected by this option change from component to component. This flag has no effect in <a href="qurl.html#toString">toString</a>() or <a href="qurl.html#toEncoded">toEncoded</a>().</td></tr>
<tr><td class="topAlign"><code>QUrl::EncodeReserved</code></td><td class="topAlign tblval"><code>0x1000000</code></td><td class="topAlign">Leave US-ASCII characters not permitted in the URL by the specification in their encoded form. This is the default on <a href="qurl.html#toString">toString</a>() and <a href="qurl.html#toEncoded">toEncoded</a>().</td></tr>
<tr><td class="topAlign"><code>QUrl::DecodeReserved</code></td><td class="topAlign tblval"><code>0x2000000</code></td><td class="topAlign">Decode the US-ASCII characters that the URL specification does not allow to appear in the URL. This is the default on the getters of individual components.</td></tr>
<tr><td class="topAlign"><code>QUrl::FullyEncoded</code></td><td class="topAlign tblval"><code>EncodeSpaces | EncodeUnicode | EncodeDelimiters | EncodeReserved</code></td><td class="topAlign">Leave all characters in their properly-encoded form, as this component would appear as part of a URL. When used with <a href="qurl.html#toString">toString</a>(), this produces a fully-compliant URL in <a href="qstring.html">QString</a> form, exactly equal to the result of <a href="qurl.html#toEncoded">toEncoded</a>()</td></tr>
<tr><td class="topAlign"><code>QUrl::FullyDecoded</code></td><td class="topAlign tblval"><code>FullyEncoded | DecodeReserved | 0x4000000</code></td><td class="topAlign">Attempt to decode as much as possible. For individual components of the URL, this decodes every percent encoding sequence, including control characters (U+0000 to U+001F) and UTF-8 sequences found in percent-encoded form. Use of this mode may cause data loss, see below for more information.</td></tr>
</table></div>
<p>The values of EncodeReserved and DecodeReserved should not be used together in one call. The behavior is undefined if that happens. They are provided as separate values because the behavior of the &quot;pretty mode&quot; with regards to reserved characters is different on certain components and specially on the full URL.</p>
<a name="full-decoding"></a>
<h5 id="full-decoding">Full decoding</h5>
<p>The FullyDecoded mode is similar to the behavior of the functions returning <a href="qstring.html">QString</a> in Qt 4.x, in that every character represents itself and never has any special meaning. This is true even for the percent character ('%'), which should be interpreted to mean a literal percent, not the beginning of a percent-encoded sequence. The same actual character, in all other decoding modes, is represented by the sequence &quot;%25&quot;.</p>
<p>Whenever re-applying data obtained with QUrl::FullyDecoded into a <a href="qurl.html">QUrl</a>, care must be taken to use the <a href="qurl.html#ParsingMode-enum">QUrl::DecodedMode</a> parameter to the setters (like <a href="qurl.html#setPath">setPath</a>() and <a href="qurl.html#setUserName">setUserName</a>()). Failure to do so may cause re-interpretation of the percent character ('%') as the beginning of a percent-encoded sequence.</p>
<p>This mode is quite useful when portions of a URL are used in a non-URL context. For example, to extract the username, password or file paths in an FTP client application, the FullyDecoded mode should be used.</p>
<p>This mode should be used with care, since there are two conditions that cannot be reliably represented in the returned <a href="qstring.html">QString</a>. They are:</p>
<ul>
<li><b>Non-UTF-8 sequences:</b> URLs may contain sequences of percent-encoded characters that do not form valid UTF-8 sequences. Since URLs need to be decoded using UTF-8, any decoder failure will result in the <a href="qstring.html">QString</a> containing one or more replacement characters where the sequence existed.</li>
<li><b>Encoded delimiters:</b> URLs are also allowed to make a distinction between a delimiter found in its literal form and its equivalent in percent-encoded form. This is most commonly found in the query, but is permitted in most parts of the URL.</li>
</ul>
<p>The following example illustrates the problem:</p>
<pre class="cpp">

      <span class="type"><a href="qurl.html#QUrl">QUrl</a></span> original(<span class="string">&quot;http://example.com/?q=a%2B%3Db%26c&quot;</span>);
      <span class="type"><a href="qurl.html#QUrl">QUrl</a></span> copy(original);
      copy<span class="operator">.</span>setQuery(copy<span class="operator">.</span>query(<span class="type"><a href="qurl.html#QUrl">QUrl</a></span><span class="operator">::</span>FullyDecoded)<span class="operator">,</span> <span class="type"><a href="qurl.html#QUrl">QUrl</a></span><span class="operator">::</span>DecodedMode);

      <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> original<span class="operator">.</span>toString();   <span class="comment">// prints: http://example.com/?q=a%2B%3Db%26c</span>
      <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> copy<span class="operator">.</span>toString();       <span class="comment">// prints: http://example.com/?q=a+=b&amp;c</span>

</pre>
<p>If the two URLs were used via HTTP GET, the interpretation by the web server would probably be different. In the first case, it would interpret as one parameter, with a key of &quot;q&quot; and value &quot;a+=b&amp;c&quot;. In the second case, it would probably interpret as two parameters, one with a key of &quot;q&quot; and value &quot;a =b&quot;, and the second with a key &quot;c&quot; and no value.</p>
<p>This enum was introduced or modified in  Qt 5.0.</p>
<p>The ComponentFormattingOptions type is a typedef for <a href="qflags.html">QFlags</a>&lt;ComponentFormattingOption&gt;. It stores an OR combination of ComponentFormattingOption values.</p>
<p><b>See also </b><a href="qurl.html#UrlFormattingOption-enum">QUrl::FormattingOptions</a>.</p>
<!-- @@@ComponentFormattingOption -->
<!-- $$$ParsingMode$$$TolerantMode$$$StrictMode$$$DecodedMode -->
<h3 class="fn" id="ParsingMode-enum"><a name="ParsingMode-enum"></a>enum QUrl::<span class="name">ParsingMode</span></h3>
<p>The parsing mode controls the way <a href="qurl.html">QUrl</a> parses strings.</p>
<div class="table"><table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><code>QUrl::TolerantMode</code></td><td class="topAlign tblval"><code>0</code></td><td class="topAlign"><a href="qurl.html">QUrl</a> will try to correct some common errors in URLs. This mode is useful for parsing URLs coming from sources not known to be strictly standards-conforming.</td></tr>
<tr><td class="topAlign"><code>QUrl::StrictMode</code></td><td class="topAlign tblval"><code>1</code></td><td class="topAlign">Only valid URLs are accepted. This mode is useful for general URL validation.</td></tr>
<tr><td class="topAlign"><code>QUrl::DecodedMode</code></td><td class="topAlign tblval"><code>2</code></td><td class="topAlign"><a href="qurl.html">QUrl</a> will interpret the URL component in the fully-decoded form, where percent characters stand for themselves, not as the beginning of a percent-encoded sequence. This mode is only valid for the setters setting components of a URL; it is not permitted in the <a href="qurl.html">QUrl</a> constructor, in <a href="qurl.html#fromEncoded">fromEncoded</a>() or in <a href="qurl.html#setUrl">setUrl</a>(). For more information on this mode, see the documentation for <a href="qurl.html#ComponentFormattingOption-enum">QUrl::FullyDecoded</a>.</td></tr>
</table></div>
<p>In TolerantMode, the parser has the following behaviour:</p>
<ul>
<li>Spaces and &quot;%20&quot;: unencoded space characters will be accepted and will be treated as equivalent to &quot;%20&quot;.</li>
<li>Single &quot;%&quot; characters: Any occurrences of a percent character &quot;%&quot; not followed by exactly two hexadecimal characters (e.g&#x2e;, &quot;13% coverage.html&quot;) will be replaced by &quot;%25&quot;. Note that one lone &quot;%&quot; character will trigger the correction mode for all percent characters.</li>
<li>Reserved and unreserved characters: An encoded URL should only contain a few characters as literals; all other characters should be percent-encoded. In TolerantMode, these characters will be accepted if they are found in the URL: space / double-quote / &quot;&lt;&quot; / &quot;&gt;&quot; / &quot;&quot; / &quot;^&quot; / &quot;`&quot; / &quot;{&quot; / &quot;|&quot; / &quot;}&quot; Those same characters can be decoded again by passing <a href="qurl.html#ComponentFormattingOption-enum">QUrl::DecodeReserved</a> to <a href="qurl.html#toString">toString</a>() or <a href="qurl.html#toEncoded">toEncoded</a>(). In the getters of individual components, those characters are often returned in decoded form.</li>
</ul>
<p>When in StrictMode, if a parsing error is found, <a href="qurl.html#isValid">isValid</a>() will return <code>false</code> and <a href="qurl.html#errorString">errorString</a>() will return a message describing the error. If more than one error is detected, it is undefined which error gets reported.</p>
<p>Note that TolerantMode is not usually enough for parsing user input, which often contains more errors and expectations than the parser can deal with. When dealing with data coming directly from the user -- as opposed to data coming from data-transfer sources, such as other programs -- it is recommended to use <a href="qurl.html#fromUserInput">fromUserInput</a>().</p>
<p><b>See also </b><a href="qurl.html#fromUserInput">fromUserInput</a>(), <a href="qurl.html#setUrl">setUrl</a>(), <a href="qurl.html#toString">toString</a>(), <a href="qurl.html#toEncoded">toEncoded</a>(), and <a href="qurl.html#UrlFormattingOption-enum">QUrl::FormattingOptions</a>.</p>
<!-- @@@ParsingMode -->
<!-- $$$UrlFormattingOption$$$None$$$RemoveScheme$$$RemovePassword$$$RemoveUserInfo$$$RemovePort$$$RemoveAuthority$$$RemovePath$$$RemoveQuery$$$RemoveFragment$$$PreferLocalFile$$$StripTrailingSlash$$$RemoveFilename$$$NormalizePathSegments -->
<h3 class="flags" id="UrlFormattingOption-enum"><a name="UrlFormattingOption-enum"></a>enum QUrl::<span class="name">UrlFormattingOption</span><br/>flags QUrl::<span class="name">FormattingOptions</span></h3>
<p>The formatting options define how the URL is formatted when written out as text.</p>
<div class="table"><table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><code>QUrl::None</code></td><td class="topAlign tblval"><code>0x0</code></td><td class="topAlign">The format of the URL is unchanged.</td></tr>
<tr><td class="topAlign"><code>QUrl::RemoveScheme</code></td><td class="topAlign tblval"><code>0x1</code></td><td class="topAlign">The scheme is removed from the URL.</td></tr>
<tr><td class="topAlign"><code>QUrl::RemovePassword</code></td><td class="topAlign tblval"><code>0x2</code></td><td class="topAlign">Any password in the URL is removed.</td></tr>
<tr><td class="topAlign"><code>QUrl::RemoveUserInfo</code></td><td class="topAlign tblval"><code>RemovePassword | 0x4</code></td><td class="topAlign">Any user information in the URL is removed.</td></tr>
<tr><td class="topAlign"><code>QUrl::RemovePort</code></td><td class="topAlign tblval"><code>0x8</code></td><td class="topAlign">Any specified port is removed from the URL.</td></tr>
<tr><td class="topAlign"><code>QUrl::RemoveAuthority</code></td><td class="topAlign tblval"><code>RemoveUserInfo | RemovePort | 0x10</code></td><td class="topAlign">&nbsp;</td></tr>
<tr><td class="topAlign"><code>QUrl::RemovePath</code></td><td class="topAlign tblval"><code>0x20</code></td><td class="topAlign">The URL's path is removed, leaving only the scheme, host address, and port (if present).</td></tr>
<tr><td class="topAlign"><code>QUrl::RemoveQuery</code></td><td class="topAlign tblval"><code>0x40</code></td><td class="topAlign">The query part of the URL (following a '?' character) is removed.</td></tr>
<tr><td class="topAlign"><code>QUrl::RemoveFragment</code></td><td class="topAlign tblval"><code>0x80</code></td><td class="topAlign">&nbsp;</td></tr>
<tr><td class="topAlign"><code>QUrl::RemoveFilename</code></td><td class="topAlign tblval"><code>0x800</code></td><td class="topAlign">The filename (i.e&#x2e; everything after the last '/' in the path) is removed. The trailing '/' is kept, unless StripTrailingSlash is set. Only valid if RemovePath is not set.</td></tr>
<tr><td class="topAlign"><code>QUrl::PreferLocalFile</code></td><td class="topAlign tblval"><code>0x200</code></td><td class="topAlign">If the URL is a local file according to <a href="qurl.html#isLocalFile">isLocalFile</a>() and contains no query or fragment, a local file path is returned.</td></tr>
<tr><td class="topAlign"><code>QUrl::StripTrailingSlash</code></td><td class="topAlign tblval"><code>0x400</code></td><td class="topAlign">The trailing slash is removed from the path, if one is present.</td></tr>
<tr><td class="topAlign"><code>QUrl::NormalizePathSegments</code></td><td class="topAlign tblval"><code>0x1000</code></td><td class="topAlign">Modifies the path to remove redundant directory separators, and to resolve &quot;.&quot;s and &quot;..&quot;s (as far as possible). For non-local paths, adjacent slashes are preserved.</td></tr>
</table></div>
<p>Note that the case folding rules in Nameprep, which <a href="qurl.html">QUrl</a> conforms to, require host names to always be converted to lower case, regardless of the Qt::FormattingOptions used.</p>
<p>The options from <a href="qurl.html#ComponentFormattingOption-enum">QUrl::ComponentFormattingOptions</a> are also possible.</p>
<p>The FormattingOptions type is a typedef for <a href="qflags.html">QFlags</a>&lt;UrlFormattingOption&gt;. It stores an OR combination of UrlFormattingOption values.</p>
<p><b>See also </b><a href="qurl.html#ComponentFormattingOption-enum">QUrl::ComponentFormattingOptions</a>.</p>
<!-- @@@UrlFormattingOption -->
<!-- $$$UserInputResolutionOption$$$DefaultResolution$$$AssumeLocalFile -->
<h3 class="flags" id="UserInputResolutionOption-enum"><a name="UserInputResolutionOption-enum"></a>enum QUrl::<span class="name">UserInputResolutionOption</span><br/>flags QUrl::<span class="name">UserInputResolutionOptions</span></h3>
<p>The user input resolution options define how <a href="qurl.html#fromUserInput">fromUserInput</a>() should interpret strings that could either be a relative path or the short form of a HTTP URL. For instance <code>file.pl</code> can be either a local file or the URL <code>http://file.pl</code>.</p>
<div class="table"><table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><code>QUrl::DefaultResolution</code></td><td class="topAlign tblval"><code>0</code></td><td class="topAlign">The default resolution mechanism is to check whether a local file exists, in the working directory given to <a href="qurl.html#fromUserInput">fromUserInput</a>, and only return a local path in that case. Otherwise a URL is assumed.</td></tr>
<tr><td class="topAlign"><code>QUrl::AssumeLocalFile</code></td><td class="topAlign tblval"><code>1</code></td><td class="topAlign">This option makes <a href="qurl.html#fromUserInput">fromUserInput</a>() always return a local path unless the input contains a scheme, such as <code>http://file.pl</code>. This is useful for applications such as text editors, which are able to create the file if it doesn't exist.</td></tr>
</table></div>
<p>This enum was introduced or modified in  Qt 5.4.</p>
<p>The UserInputResolutionOptions type is a typedef for <a href="qflags.html">QFlags</a>&lt;UserInputResolutionOption&gt;. It stores an OR combination of UserInputResolutionOption values.</p>
<p><b>See also </b><a href="qurl.html#fromUserInput">fromUserInput</a>().</p>
<!-- @@@UserInputResolutionOption -->
</div>
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QUrl[overload1]$$$QUrl -->
<h3 class="fn" id="QUrl"><a name="QUrl"></a>QUrl::<span class="name">QUrl</span>()</h3>
<p>Constructs an empty <a href="qurl.html">QUrl</a> object.</p>
<!-- @@@QUrl -->
<!-- $$$QUrl$$$QUrlconstQUrl& -->
<h3 class="fn" id="QUrl-1"><a name="QUrl-1"></a>QUrl::<span class="name">QUrl</span>(const <span class="type"><a href="qurl.html#QUrl">QUrl</a></span> &amp;<i>other</i>)</h3>
<p>Constructs a copy of <i>other</i>.</p>
<!-- @@@QUrl -->
<!-- $$$QUrl$$$QUrlconstQString&QUrl::ParsingMode -->
<h3 class="fn" id="QUrl-2"><a name="QUrl-2"></a>QUrl::<span class="name">QUrl</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>url</i>, <span class="type"><a href="qurl.html#ParsingMode-enum">QUrl::ParsingMode</a></span> <i>parsingMode</i> = TolerantMode)</h3>
<p>Constructs a URL by parsing <i>url</i>. <a href="qurl.html">QUrl</a> will automatically percent encode all characters that are not allowed in a URL and decode the percent-encoded sequences that represent an unreserved character (letters, digits, hyphens, undercores, dots and tildes). All other characters are left in their original forms.</p>
<p>Parses the <i>url</i> using the parser mode <i>parsingMode</i>. In <a href="qurl.html#ParsingMode-enum">TolerantMode</a> (the default), <a href="qurl.html">QUrl</a> will correct certain mistakes, notably the presence of a percent character ('%') not followed by two hexadecimal digits, and it will accept any character in any position. In <a href="qurl.html#ParsingMode-enum">StrictMode</a>, encoding mistakes will not be tolerated and <a href="qurl.html">QUrl</a> will also check that certain forbidden characters are not present in unencoded form. If an error is detected in <a href="qurl.html#ParsingMode-enum">StrictMode</a>, <a href="qurl.html#isValid">isValid</a>() will return false. The parsing mode <a href="qurl.html#ParsingMode-enum">DecodedMode</a> is not permitted in this context.</p>
<p>Example:</p>
<pre class="cpp">

  <span class="type"><a href="qurl.html#QUrl">QUrl</a></span> url(<span class="string">&quot;http://www.example.com/List of holidays.xml&quot;</span>);
  <span class="comment">// url.toEncoded() == &quot;http://www.example.com/List%20of%20holidays.xml&quot;</span>

</pre>
<p>To construct a URL from an encoded string, you can also use <a href="qurl.html#fromEncoded">fromEncoded</a>():</p>
<pre class="cpp">

  <span class="type"><a href="qurl.html#QUrl">QUrl</a></span> url <span class="operator">=</span> <span class="type"><a href="qurl.html#QUrl">QUrl</a></span><span class="operator">::</span>fromEncoded(<span class="string">&quot;http://qt-project.org/List%20of%20holidays.xml&quot;</span>);

</pre>
<p>Both functions are equivalent and, in Qt 5, both functions accept encoded data. Usually, the choice of the <a href="qurl.html">QUrl</a> constructor or <a href="qurl.html#setUrl">setUrl</a>() versus <a href="qurl.html#fromEncoded">fromEncoded</a>() will depend on the source data: the constructor and <a href="qurl.html#setUrl">setUrl</a>() take a <a href="qstring.html">QString</a>, whereas <a href="qurl.html#fromEncoded">fromEncoded</a> takes a <a href="qbytearray.html">QByteArray</a>.</p>
<p><b>See also </b><a href="qurl.html#setUrl">setUrl</a>(), <a href="qurl.html#fromEncoded">fromEncoded</a>(), and <a href="qurl.html#ParsingMode-enum">TolerantMode</a>.</p>
<!-- @@@QUrl -->
<!-- $$$QUrl$$$QUrlQUrl&& -->
<h3 class="fn" id="QUrl-3"><a name="QUrl-3"></a>QUrl::<span class="name">QUrl</span>(<span class="type"><a href="qurl.html#QUrl">QUrl</a></span> &amp;&amp;<i>other</i>)</h3>
<p>Move-constructs a <a href="qurl.html">QUrl</a> instance, making it point at the same object that <i>other</i> was pointing to.</p>
<p>This function was introduced in  Qt 5.2.</p>
<!-- @@@QUrl -->
<!-- $$$~QUrl[overload1]$$$~QUrl -->
<h3 class="fn" id="dtor.QUrl"><a name="dtor.QUrl"></a>QUrl::<span class="name">~QUrl</span>()</h3>
<p>Destructor; called immediately before the object is deleted.</p>
<!-- @@@~QUrl -->
<!-- $$$adjusted[overload1]$$$adjustedQUrl::FormattingOptions -->
<h3 class="fn" id="adjusted"><a name="adjusted"></a><span class="type"><a href="qurl.html#QUrl">QUrl</a></span> QUrl::<span class="name">adjusted</span>(<span class="type"><a href="qurl.html#UrlFormattingOption-enum">QUrl::FormattingOptions</a></span> <i>options</i>) const</h3>
<p>Returns an adjusted version of the URL. The output can be customized by passing flags with <i>options</i>.</p>
<p>The encoding options from <a href="qurl.html#ComponentFormattingOption-enum">QUrl::ComponentFormattingOption</a> don't make much sense for this method, nor does <a href="qurl.html#UrlFormattingOption-enum">QUrl::PreferLocalFile</a>.</p>
<p>This is always equivalent to <a href="qurl.html">QUrl</a>(url.<a href="qurl.html#toString">toString</a>(options)).</p>
<p>This function was introduced in  Qt 5.2.</p>
<p><b>See also </b><a href="qurl.html#UrlFormattingOption-enum">FormattingOptions</a>, <a href="qurl.html#toEncoded">toEncoded</a>(), and <a href="qurl.html#toString">toString</a>().</p>
<!-- @@@adjusted -->
<!-- $$$authority[overload1]$$$authorityQUrl::ComponentFormattingOptions -->
<h3 class="fn" id="authority"><a name="authority"></a><span class="type"><a href="qstring.html">QString</a></span> QUrl::<span class="name">authority</span>(<span class="type"><a href="qurl.html#ComponentFormattingOption-enum">QUrl::ComponentFormattingOptions</a></span> <i>options</i> = PrettyDecoded) const</h3>
<p>Returns the authority of the URL if it is defined; otherwise an empty string is returned.</p>
<p>This function returns an unambiguous value, which may contain that characters still percent-encoded, plus some control sequences not representable in decoded form in <a href="qstring.html">QString</a>.</p>
<p>The <i>options</i> argument controls how to format the user info component. The value of <a href="qurl.html#ComponentFormattingOption-enum">QUrl::FullyDecoded</a> is not permitted in this function. If you need to obtain fully decoded data, call <a href="qurl.html#userName">userName</a>(), <a href="qurl.html#password">password</a>(), <a href="qurl.html#host">host</a>() and <a href="qurl.html#port">port</a>() individually.</p>
<p><b>See also </b><a href="qurl.html#setAuthority">setAuthority</a>(), <a href="qurl.html#userInfo">userInfo</a>(), <a href="qurl.html#userName">userName</a>(), <a href="qurl.html#password">password</a>(), <a href="qurl.html#host">host</a>(), and <a href="qurl.html#port">port</a>().</p>
<!-- @@@authority -->
<!-- $$$clear[overload1]$$$clear -->
<h3 class="fn" id="clear"><a name="clear"></a><span class="type">void</span> QUrl::<span class="name">clear</span>()</h3>
<p>Resets the content of the <a href="qurl.html">QUrl</a>. After calling this function, the <a href="qurl.html">QUrl</a> is equal to one that has been constructed with the default empty constructor.</p>
<p><b>See also </b><a href="qurl.html#isEmpty">isEmpty</a>().</p>
<!-- @@@clear -->
<!-- $$$errorString[overload1]$$$errorString -->
<h3 class="fn" id="errorString"><a name="errorString"></a><span class="type"><a href="qstring.html">QString</a></span> QUrl::<span class="name">errorString</span>() const</h3>
<p>Returns an error message if the last operation that modified this <a href="qurl.html">QUrl</a> object ran into a parsing error. If no error was detected, this function returns an empty string and <a href="qurl.html#isValid">isValid</a>() returns <code>true</code>.</p>
<p>The error message returned by this function is technical in nature and may not be understood by end users. It is mostly useful to developers trying to understand why <a href="qurl.html">QUrl</a> will not accept some input.</p>
<p>This function was introduced in  Qt 4.2.</p>
<p><b>See also </b><a href="qurl.html#ParsingMode-enum">QUrl::ParsingMode</a>.</p>
<!-- @@@errorString -->
<!-- $$$fileName[overload1]$$$fileNameQUrl::ComponentFormattingOptions -->
<h3 class="fn" id="fileName"><a name="fileName"></a><span class="type"><a href="qstring.html">QString</a></span> QUrl::<span class="name">fileName</span>(<span class="type"><a href="qurl.html#ComponentFormattingOption-enum">QUrl::ComponentFormattingOptions</a></span> <i>options</i> = FullyDecoded) const</h3>
<p>Returns the name of the file, excluding the directory path.</p>
<p>Note that, if this <a href="qurl.html">QUrl</a> object is given a path ending in a slash, the name of the file is considered empty.</p>
<p>If the path doesn't contain any slash, it is fully returned as the fileName.</p>
<p>Example:</p>
<pre class="cpp">

  <span class="type"><a href="qurl.html#QUrl">QUrl</a></span> url(<span class="string">&quot;http://qt-project.org/support/file.html&quot;</span>);
  <span class="comment">// url.adjusted(RemoveFilename) == &quot;http://qt-project.org/support/&quot;</span>
  <span class="comment">// url.fileName() == &quot;file.html&quot;</span>

</pre>
<p>The <i>options</i> argument controls how to format the file name component. All values produce an unambiguous result. With <a href="qurl.html#ComponentFormattingOption-enum">QUrl::FullyDecoded</a>, all percent-encoded sequences are decoded; otherwise, the returned value may contain some percent-encoded sequences for some control sequences not representable in decoded form in <a href="qstring.html">QString</a>.</p>
<p>This function was introduced in  Qt 5.2.</p>
<p><b>See also </b><a href="qurl.html#path">path</a>().</p>
<!-- @@@fileName -->
<!-- $$$fragment[overload1]$$$fragmentQUrl::ComponentFormattingOptions -->
<h3 class="fn" id="fragment"><a name="fragment"></a><span class="type"><a href="qstring.html">QString</a></span> QUrl::<span class="name">fragment</span>(<span class="type"><a href="qurl.html#ComponentFormattingOption-enum">QUrl::ComponentFormattingOptions</a></span> <i>options</i> = PrettyDecoded) const</h3>
<p>Returns the fragment of the URL. To determine if the parsed URL contained a fragment, use <a href="qurl.html#hasFragment">hasFragment</a>().</p>
<p>The <i>options</i> argument controls how to format the fragment component. All values produce an unambiguous result. With <a href="qurl.html#ComponentFormattingOption-enum">QUrl::FullyDecoded</a>, all percent-encoded sequences are decoded; otherwise, the returned value may contain some percent-encoded sequences for some control sequences not representable in decoded form in <a href="qstring.html">QString</a>.</p>
<p>Note that <a href="qurl.html#ComponentFormattingOption-enum">QUrl::FullyDecoded</a> may cause data loss if those non-representable sequences are present. It is recommended to use that value when the result will be used in a non-URL context.</p>
<p><b>See also </b><a href="qurl.html#setFragment">setFragment</a>() and <a href="qurl.html#hasFragment">hasFragment</a>().</p>
<!-- @@@fragment -->
<!-- $$$fromAce[overload1]$$$fromAceconstQByteArray& -->
<h3 class="fn" id="fromAce"><a name="fromAce"></a><code>[static] </code><span class="type"><a href="qstring.html">QString</a></span> QUrl::<span class="name">fromAce</span>(const <span class="type"><a href="qbytearray.html">QByteArray</a></span> &amp;<i>domain</i>)</h3>
<p>Returns the Unicode form of the given domain name <i>domain</i>, which is encoded in the ASCII Compatible Encoding (ACE). The result of this function is considered equivalent to <i>domain</i>.</p>
<p>If the value in <i>domain</i> cannot be encoded, it will be converted to <a href="qstring.html">QString</a> and returned.</p>
<p>The ASCII Compatible Encoding (ACE) is defined by RFC 3490, RFC 3491 and RFC 3492. It is part of the Internationalizing Domain Names in Applications (IDNA) specification, which allows for domain names (like <code>&quot;example.com&quot;</code>) to be written using international characters.</p>
<p>This function was introduced in  Qt 4.2.</p>
<!-- @@@fromAce -->
<!-- $$$fromCFURL[overload1]$$$fromCFURLCFURLRef -->
<h3 class="fn" id="fromCFURL"><a name="fromCFURL"></a><code>[static] </code><span class="type"><a href="qurl.html#QUrl">QUrl</a></span> QUrl::<span class="name">fromCFURL</span>(<span class="type">CFURLRef</span> <i>url</i>)</h3>
<p>Constructs a <a href="qurl.html">QUrl</a> containing a copy of the CFURL <i>url</i>.</p>
<p>This function was introduced in  Qt 5.2.</p>
<!-- @@@fromCFURL -->
<!-- $$$fromEncoded[overload1]$$$fromEncodedconstQByteArray&QUrl::ParsingMode -->
<h3 class="fn" id="fromEncoded"><a name="fromEncoded"></a><code>[static] </code><span class="type"><a href="qurl.html#QUrl">QUrl</a></span> QUrl::<span class="name">fromEncoded</span>(const <span class="type"><a href="qbytearray.html">QByteArray</a></span> &amp;<i>input</i>, <span class="type"><a href="qurl.html#ParsingMode-enum">QUrl::ParsingMode</a></span> <i>parsingMode</i> = TolerantMode)</h3>
<p>Parses <i>input</i> and returns the corresponding <a href="qurl.html">QUrl</a>. <i>input</i> is assumed to be in encoded form, containing only ASCII characters.</p>
<p>Parses the URL using <i>parsingMode</i>. See <a href="qurl.html#setUrl">setUrl</a>() for more information on this parameter. <a href="qurl.html#ParsingMode-enum">QUrl::DecodedMode</a> is not permitted in this context.</p>
<p><b>See also </b><a href="qurl.html#toEncoded">toEncoded</a>() and <a href="qurl.html#setUrl">setUrl</a>().</p>
<!-- @@@fromEncoded -->
<!-- $$$fromLocalFile[overload1]$$$fromLocalFileconstQString& -->
<h3 class="fn" id="fromLocalFile"><a name="fromLocalFile"></a><code>[static] </code><span class="type"><a href="qurl.html#QUrl">QUrl</a></span> QUrl::<span class="name">fromLocalFile</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>localFile</i>)</h3>
<p>Returns a <a href="qurl.html">QUrl</a> representation of <i>localFile</i>, interpreted as a local file. This function accepts paths separated by slashes as well as the native separator for this platform.</p>
<p>This function also accepts paths with a doubled leading slash (or backslash) to indicate a remote file, as in &quot;//servername/path/to/file.txt&quot;. Note that only certain platforms can actually open this file using <a href="qfile.html#open">QFile::open</a>().</p>
<p>An empty <i>localFile</i> leads to an empty URL (since Qt 5.4).</p>
<pre class="cpp">

      <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="type"><a href="qurl.html#QUrl">QUrl</a></span><span class="operator">::</span>fromLocalFile(<span class="string">&quot;file.txt&quot;</span>);            <span class="comment">// QUrl(&quot;file:file.txt&quot;)</span>
      <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="type"><a href="qurl.html#QUrl">QUrl</a></span><span class="operator">::</span>fromLocalFile(<span class="string">&quot;/home/user/file.txt&quot;</span>); <span class="comment">// QUrl(&quot;file:///home/user/file.txt&quot;)</span>
      <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="type"><a href="qurl.html#QUrl">QUrl</a></span><span class="operator">::</span>fromLocalFile(<span class="string">&quot;file:file.txt&quot;</span>);       <span class="comment">// doesn't make sense; expects path, not url with scheme</span>

</pre>
<p>In the first line in snippet above, a file URL is constructed from a local, relative path. A file URL with a relative path only makes sense if there is a base URL to resolve it against. For example:</p>
<pre class="cpp">

      <span class="type"><a href="qurl.html#QUrl">QUrl</a></span> url <span class="operator">=</span> <span class="type"><a href="qurl.html#QUrl">QUrl</a></span><span class="operator">::</span>fromLocalFile(<span class="string">&quot;file.txt&quot;</span>);
      <span class="type"><a href="qurl.html#QUrl">QUrl</a></span> baseUrl <span class="operator">=</span> <span class="type"><a href="qurl.html#QUrl">QUrl</a></span>(<span class="string">&quot;file:/home/user/&quot;</span>);
      <span class="comment">// wrong: prints QUrl(&quot;file:file.txt&quot;), as url already has a scheme</span>
      <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> baseUrl<span class="operator">.</span>resolved(url);

</pre>
<p>To resolve such a URL, it's necessary to remove the scheme beforehand:</p>
<pre class="cpp">

      <span class="comment">// correct: prints QUrl(&quot;file:///home/user/file.txt&quot;)</span>
      url<span class="operator">.</span>setScheme(<span class="type"><a href="qstring.html">QString</a></span>());
      <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> baseUrl<span class="operator">.</span>resolved(url);

</pre>
<p>For this reason, it is better to use a relative URL (that is, no scheme) for relative file paths:</p>
<pre class="cpp">

      <span class="type"><a href="qurl.html#QUrl">QUrl</a></span> url <span class="operator">=</span> <span class="type"><a href="qurl.html#QUrl">QUrl</a></span>(<span class="string">&quot;file.txt&quot;</span>);
      <span class="type"><a href="qurl.html#QUrl">QUrl</a></span> baseUrl <span class="operator">=</span> <span class="type"><a href="qurl.html#QUrl">QUrl</a></span>(<span class="string">&quot;file:/home/user/&quot;</span>);
      <span class="comment">// prints QUrl(&quot;file:///home/user/file.txt&quot;)</span>
      <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> baseUrl<span class="operator">.</span>resolved(url);

</pre>
<p><b>See also </b><a href="qurl.html#toLocalFile">toLocalFile</a>(), <a href="qurl.html#isLocalFile">isLocalFile</a>(), and <a href="qdir.html#toNativeSeparators">QDir::toNativeSeparators</a>().</p>
<!-- @@@fromLocalFile -->
<!-- $$$fromNSURL[overload1]$$$fromNSURLconstNSURL* -->
<h3 class="fn" id="fromNSURL"><a name="fromNSURL"></a><code>[static] </code><span class="type"><a href="qurl.html#QUrl">QUrl</a></span> QUrl::<span class="name">fromNSURL</span>(const <span class="type">NSURL</span> *<i>url</i>)</h3>
<p>Constructs a <a href="qurl.html">QUrl</a> containing a copy of the NSURL <i>url</i>.</p>
<p>This function was introduced in  Qt 5.2.</p>
<!-- @@@fromNSURL -->
<!-- $$$fromPercentEncoding[overload1]$$$fromPercentEncodingconstQByteArray& -->
<h3 class="fn" id="fromPercentEncoding"><a name="fromPercentEncoding"></a><code>[static] </code><span class="type"><a href="qstring.html">QString</a></span> QUrl::<span class="name">fromPercentEncoding</span>(const <span class="type"><a href="qbytearray.html">QByteArray</a></span> &amp;<i>input</i>)</h3>
<p>Returns a decoded copy of <i>input</i>. <i>input</i> is first decoded from percent encoding, then converted from UTF-8 to unicode.</p>
<p><b>Note: </b>Given invalid input (such as a string containing the sequence &quot;%G5&quot;, which is not a valid hexadecimal number) the output will be invalid as well. As an example: the sequence &quot;%G5&quot; could be decoded to 'W'.</p><!-- @@@fromPercentEncoding -->
<!-- $$$fromStringList[overload1]$$$fromStringListconstQStringList&QUrl::ParsingMode -->
<h3 class="fn" id="fromStringList"><a name="fromStringList"></a><code>[static] </code><span class="type"><a href="qlist.html">QList</a></span>&lt;<span class="type"><a href="qurl.html#QUrl">QUrl</a></span>&gt; QUrl::<span class="name">fromStringList</span>(const <span class="type"><a href="qstringlist.html">QStringList</a></span> &amp;<i>urls</i>, <span class="type"><a href="qurl.html#ParsingMode-enum">QUrl::ParsingMode</a></span> <i>mode</i> = TolerantMode)</h3>
<p>Converts a list of strings representing <i>urls</i> into a list of urls, using <a href="qurl.html">QUrl</a>(str, <i>mode</i>). Note that this means all strings must be urls, not for instance local paths.</p>
<p>This function was introduced in  Qt 5.1.</p>
<!-- @@@fromStringList -->
<!-- $$$fromUserInput[overload1]$$$fromUserInputconstQString& -->
<h3 class="fn" id="fromUserInput"><a name="fromUserInput"></a><code>[static] </code><span class="type"><a href="qurl.html#QUrl">QUrl</a></span> QUrl::<span class="name">fromUserInput</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>userInput</i>)</h3>
<p>Returns a valid URL from a user supplied <i>userInput</i> string if one can be deducted. In the case that is not possible, an invalid <a href="qurl.html#QUrl">QUrl</a>() is returned.</p>
<p>Most applications that can browse the web, allow the user to input a URL in the form of a plain string. This string can be manually typed into a location bar, obtained from the clipboard, or passed in via command line arguments.</p>
<p>When the string is not already a valid URL, a best guess is performed, making various web related assumptions.</p>
<p>In the case the string corresponds to a valid file path on the system, a file:// URL is constructed, using <a href="qurl.html#fromLocalFile">QUrl::fromLocalFile</a>().</p>
<p>If that is not the case, an attempt is made to turn the string into a http:// or ftp:// URL. The latter in the case the string starts with 'ftp'. The result is then passed through <a href="qurl.html">QUrl</a>'s tolerant parser, and in the case or success, a valid <a href="qurl.html">QUrl</a> is returned, or else a <a href="qurl.html#QUrl">QUrl</a>().</p>
<a name="examples"></a>
<h4 id="examples">Examples:</h4>
<ul>
<li>qt-project.org becomes http://qt-project.org</li>
<li>ftp.qt-project.org becomes ftp://ftp.qt-project.org</li>
<li>hostname becomes http://hostname</li>
<li>/home/user/test.html becomes file:///home/user/test.html</li>
</ul>
<p>This function was introduced in  Qt 4.6.</p>
<!-- @@@fromUserInput -->
<!-- $$$fromUserInput$$$fromUserInputconstQString&constQString&QUrl::UserInputResolutionOptions -->
<h3 class="fn" id="fromUserInput-1"><a name="fromUserInput-1"></a><code>[static] </code><span class="type"><a href="qurl.html#QUrl">QUrl</a></span> QUrl::<span class="name">fromUserInput</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>userInput</i>, const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>workingDirectory</i>, <span class="type"><a href="qurl.html#UserInputResolutionOption-enum">QUrl::UserInputResolutionOptions</a></span> <i>options</i> = DefaultResolution)</h3>
<p>Returns a valid URL from a user supplied <i>userInput</i> string if one can be deducted. In the case that is not possible, an invalid <a href="qurl.html#QUrl">QUrl</a>() is returned.</p>
<p>This overload takes a <i>workingDirectory</i> path, in order to be able to handle relative paths. This is especially useful when handling command line arguments. If <i>workingDirectory</i> is empty, no handling of relative paths will be done, so this method will behave like its one argument overload.</p>
<p>By default, an input string that looks like a relative path will only be treated as such if the file actually exists in the given working directory.</p>
<p>If the application can handle files that don't exist yet, it should pass the flag <a href="qurl.html#UserInputResolutionOption-enum">AssumeLocalFile</a> in <i>options</i>.</p>
<p>This function was introduced in  Qt 5.4.</p>
<!-- @@@fromUserInput -->
<!-- $$$hasFragment[overload1]$$$hasFragment -->
<h3 class="fn" id="hasFragment"><a name="hasFragment"></a><span class="type">bool</span> QUrl::<span class="name">hasFragment</span>() const</h3>
<p>Returns <code>true</code> if this URL contains a fragment (i.e&#x2e;, if # was seen on it).</p>
<p>This function was introduced in  Qt 4.2.</p>
<p><b>See also </b><a href="qurl.html#fragment">fragment</a>() and <a href="qurl.html#setFragment">setFragment</a>().</p>
<!-- @@@hasFragment -->
<!-- $$$hasQuery[overload1]$$$hasQuery -->
<h3 class="fn" id="hasQuery"><a name="hasQuery"></a><span class="type">bool</span> QUrl::<span class="name">hasQuery</span>() const</h3>
<p>Returns <code>true</code> if this URL contains a Query (i.e&#x2e;, if ? was seen on it).</p>
<p>This function was introduced in  Qt 4.2.</p>
<p><b>See also </b><a href="qurl.html#setQuery">setQuery</a>(), <a href="qurl.html#query">query</a>(), and <a href="qurl.html#hasFragment">hasFragment</a>().</p>
<!-- @@@hasQuery -->
<!-- $$$host[overload1]$$$hostQUrl::ComponentFormattingOptions -->
<h3 class="fn" id="host"><a name="host"></a><span class="type"><a href="qstring.html">QString</a></span> QUrl::<span class="name">host</span>(<span class="type"><a href="qurl.html#ComponentFormattingOption-enum">QUrl::ComponentFormattingOptions</a></span> <i>options</i> = FullyDecoded) const</h3>
<p>Returns the host of the URL if it is defined; otherwise an empty string is returned.</p>
<p>The <i>options</i> argument controls how the hostname will be formatted. The <a href="qurl.html#ComponentFormattingOption-enum">QUrl::EncodeUnicode</a> option will cause this function to return the hostname in the ASCII-Compatible Encoding (ACE) form, which is suitable for use in channels that are not 8-bit clean or that require the legacy hostname (such as DNS requests or in HTTP request headers). If that flag is not present, this function returns the International Domain Name (IDN) in Unicode form, according to the list of permissible top-level domains (see <a href="qurl.html#idnWhitelist">idnWhitelist</a>()).</p>
<p>All other flags are ignored. Host names cannot contain control or percent characters, so the returned value can be considered fully decoded.</p>
<p><b>See also </b><a href="qurl.html#setHost">setHost</a>(), <a href="qurl.html#idnWhitelist">idnWhitelist</a>(), <a href="qurl.html#setIdnWhitelist">setIdnWhitelist</a>(), and <a href="qurl.html#authority">authority</a>().</p>
<!-- @@@host -->
<!-- $$$idnWhitelist[overload1]$$$idnWhitelist -->
<h3 class="fn" id="idnWhitelist"><a name="idnWhitelist"></a><code>[static] </code><span class="type"><a href="qstringlist.html">QStringList</a></span> QUrl::<span class="name">idnWhitelist</span>()</h3>
<p>Returns the current whitelist of top-level domains that are allowed to have non-ASCII characters in their compositions.</p>
<p>See <a href="qurl.html#setIdnWhitelist">setIdnWhitelist</a>() for the rationale of this list.</p>
<p>This function was introduced in  Qt 4.2.</p>
<p><b>See also </b><a href="qurl.html#setIdnWhitelist">setIdnWhitelist</a>().</p>
<!-- @@@idnWhitelist -->
<!-- $$$isEmpty[overload1]$$$isEmpty -->
<h3 class="fn" id="isEmpty"><a name="isEmpty"></a><span class="type">bool</span> QUrl::<span class="name">isEmpty</span>() const</h3>
<p>Returns <code>true</code> if the URL has no data; otherwise returns <code>false</code>.</p>
<p><b>See also </b><a href="qurl.html#clear">clear</a>().</p>
<!-- @@@isEmpty -->
<!-- $$$isLocalFile[overload1]$$$isLocalFile -->
<h3 class="fn" id="isLocalFile"><a name="isLocalFile"></a><span class="type">bool</span> QUrl::<span class="name">isLocalFile</span>() const</h3>
<p>Returns <code>true</code> if this URL is pointing to a local file path. A URL is a local file path if the scheme is &quot;file&quot;.</p>
<p>Note that this function considers URLs with hostnames to be local file paths, even if the eventual file path cannot be opened with <a href="qfile.html#open">QFile::open</a>().</p>
<p>This function was introduced in  Qt 4.8.</p>
<p><b>See also </b><a href="qurl.html#fromLocalFile">fromLocalFile</a>() and <a href="qurl.html#toLocalFile">toLocalFile</a>().</p>
<!-- @@@isLocalFile -->
<!-- $$$isParentOf[overload1]$$$isParentOfconstQUrl& -->
<h3 class="fn" id="isParentOf"><a name="isParentOf"></a><span class="type">bool</span> QUrl::<span class="name">isParentOf</span>(const <span class="type"><a href="qurl.html#QUrl">QUrl</a></span> &amp;<i>childUrl</i>) const</h3>
<p>Returns <code>true</code> if this URL is a parent of <i>childUrl</i>. <i>childUrl</i> is a child of this URL if the two URLs share the same scheme and authority, and this URL's path is a parent of the path of <i>childUrl</i>.</p>
<!-- @@@isParentOf -->
<!-- $$$isRelative[overload1]$$$isRelative -->
<h3 class="fn" id="isRelative"><a name="isRelative"></a><span class="type">bool</span> QUrl::<span class="name">isRelative</span>() const</h3>
<p>Returns <code>true</code> if the URL is relative; otherwise returns <code>false</code>. A URL is relative reference if its scheme is undefined; this function is therefore equivalent to calling <a href="qurl.html#scheme">scheme</a>().<a href="qurl.html#isEmpty">isEmpty</a>().</p>
<p>Relative references are defined in RFC 3986 section 4.2&#x2e;</p>
<p><b>See also </b><a href="qurl.html#relative-urls-vs-relative-paths">Relative URLs vs Relative Paths</a>.</p>
<!-- @@@isRelative -->
<!-- $$$isValid[overload1]$$$isValid -->
<h3 class="fn" id="isValid"><a name="isValid"></a><span class="type">bool</span> QUrl::<span class="name">isValid</span>() const</h3>
<p>Returns <code>true</code> if the URL is non-empty and valid; otherwise returns <code>false</code>.</p>
<p>The URL is run through a conformance test. Every part of the URL must conform to the standard encoding rules of the URI standard for the URL to be reported as valid.</p>
<pre class="cpp">

  bool checkUrl(<span class="keyword">const</span> <span class="type"><a href="qurl.html#QUrl">QUrl</a></span> <span class="operator">&amp;</span>url) {
      <span class="keyword">if</span> (<span class="operator">!</span>url<span class="operator">.</span>isValid()) {
          <a href="qtglobal.html#qDebug">qDebug</a>(<span class="string">&quot;Invalid URL: %s&quot;</span><span class="operator">,</span> qUtf8Printable(url<span class="operator">.</span>toString()));
          <span class="keyword">return</span> <span class="keyword">false</span>;
      }

      <span class="keyword">return</span> <span class="keyword">true</span>;
  }

</pre>
<!-- @@@isValid -->
<!-- $$$matches[overload1]$$$matchesconstQUrl&QUrl::FormattingOptions -->
<h3 class="fn" id="matches"><a name="matches"></a><span class="type">bool</span> QUrl::<span class="name">matches</span>(const <span class="type"><a href="qurl.html#QUrl">QUrl</a></span> &amp;<i>url</i>, <span class="type"><a href="qurl.html#UrlFormattingOption-enum">QUrl::FormattingOptions</a></span> <i>options</i>) const</h3>
<p>Returns <code>true</code> if this URL and the given <i>url</i> are equal after applying <i>options</i> to both; otherwise returns <code>false</code>.</p>
<p>This is equivalent to calling adjusted(options) on both URLs and comparing the resulting urls, but faster.</p>
<p>This function was introduced in  Qt 5.2.</p>
<!-- @@@matches -->
<!-- $$$password[overload1]$$$passwordQUrl::ComponentFormattingOptions -->
<h3 class="fn" id="password"><a name="password"></a><span class="type"><a href="qstring.html">QString</a></span> QUrl::<span class="name">password</span>(<span class="type"><a href="qurl.html#ComponentFormattingOption-enum">QUrl::ComponentFormattingOptions</a></span> <i>options</i> = FullyDecoded) const</h3>
<p>Returns the password of the URL if it is defined; otherwise an empty string is returned.</p>
<p>The <i>options</i> argument controls how to format the user name component. All values produce an unambiguous result. With <a href="qurl.html#ComponentFormattingOption-enum">QUrl::FullyDecoded</a>, all percent-encoded sequences are decoded; otherwise, the returned value may contain some percent-encoded sequences for some control sequences not representable in decoded form in <a href="qstring.html">QString</a>.</p>
<p>Note that <a href="qurl.html#ComponentFormattingOption-enum">QUrl::FullyDecoded</a> may cause data loss if those non-representable sequences are present. It is recommended to use that value when the result will be used in a non-URL context, such as setting in <a href="../qtnetwork/qauthenticator.html">QAuthenticator</a> or negotiating a login.</p>
<p><b>See also </b><a href="qurl.html#setPassword">setPassword</a>().</p>
<!-- @@@password -->
<!-- $$$path[overload1]$$$pathQUrl::ComponentFormattingOptions -->
<h3 class="fn" id="path"><a name="path"></a><span class="type"><a href="qstring.html">QString</a></span> QUrl::<span class="name">path</span>(<span class="type"><a href="qurl.html#ComponentFormattingOption-enum">QUrl::ComponentFormattingOptions</a></span> <i>options</i> = FullyDecoded) const</h3>
<p>Returns the path of the URL.</p>
<pre class="cpp">

      <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="type"><a href="qurl.html#QUrl">QUrl</a></span>(<span class="string">&quot;file:file.txt&quot;</span>)<span class="operator">.</span>path();                   <span class="comment">// &quot;file.txt&quot;</span>
      <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="type"><a href="qurl.html#QUrl">QUrl</a></span>(<span class="string">&quot;/home/user/file.txt&quot;</span>)<span class="operator">.</span>path();             <span class="comment">// &quot;/home/user/file.txt&quot;</span>
      <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="type"><a href="qurl.html#QUrl">QUrl</a></span>(<span class="string">&quot;http://www.example.com/test/123&quot;</span>)<span class="operator">.</span>path(); <span class="comment">// &quot;/test/123&quot;</span>

</pre>
<p>The <i>options</i> argument controls how to format the path component. All values produce an unambiguous result. With <a href="qurl.html#ComponentFormattingOption-enum">QUrl::FullyDecoded</a>, all percent-encoded sequences are decoded; otherwise, the returned value may contain some percent-encoded sequences for some control sequences not representable in decoded form in <a href="qstring.html">QString</a>.</p>
<p>Note that <a href="qurl.html#ComponentFormattingOption-enum">QUrl::FullyDecoded</a> may cause data loss if those non-representable sequences are present. It is recommended to use that value when the result will be used in a non-URL context, such as sending to an FTP server.</p>
<p>An example of data loss is when you have non-Unicode percent-encoded sequences and use <a href="qurl.html#ComponentFormattingOption-enum">FullyDecoded</a> (the default):</p>
<pre class="cpp">

      <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="type"><a href="qurl.html#QUrl">QUrl</a></span>(<span class="string">&quot;/foo%FFbar&quot;</span>)<span class="operator">.</span>path();

</pre>
<p>In this example, there will be some level of data loss because the <code>%FF</code> cannot be converted.</p>
<p>Data loss can also occur when the path contains sub-delimiters (such as <code>+</code>):</p>
<pre class="cpp">

      <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="type"><a href="qurl.html#QUrl">QUrl</a></span>(<span class="string">&quot;/foo+bar%2B&quot;</span>)<span class="operator">.</span>path(); <span class="comment">// &quot;/foo+bar+&quot;</span>

</pre>
<p>Other decoding examples:</p>
<pre class="cpp">

      <span class="keyword">const</span> <span class="type"><a href="qurl.html#QUrl">QUrl</a></span> url(<span class="string">&quot;/tmp/Mambo %235%3F.mp3&quot;</span>);
      <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> url<span class="operator">.</span>path(<span class="type"><a href="qurl.html#QUrl">QUrl</a></span><span class="operator">::</span>FullyDecoded);  <span class="comment">// &quot;/tmp/Mambo #5?.mp3&quot;</span>
      <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> url<span class="operator">.</span>path(<span class="type"><a href="qurl.html#QUrl">QUrl</a></span><span class="operator">::</span>PrettyDecoded); <span class="comment">// &quot;/tmp/Mambo #5?.mp3&quot;</span>
      <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> url<span class="operator">.</span>path(<span class="type"><a href="qurl.html#QUrl">QUrl</a></span><span class="operator">::</span>FullyEncoded);  <span class="comment">// &quot;/tmp/Mambo%20%235%3F.mp3&quot;</span>

</pre>
<p><b>See also </b><a href="qurl.html#setPath">setPath</a>().</p>
<!-- @@@path -->
<!-- $$$port[overload1]$$$portint -->
<h3 class="fn" id="port"><a name="port"></a><span class="type">int</span> QUrl::<span class="name">port</span>(<span class="type">int</span> <i>defaultPort</i> = -1) const</h3>
<p>Returns the port of the URL, or <i>defaultPort</i> if the port is unspecified.</p>
<p>Example:</p>
<pre class="cpp">

  <span class="type"><a href="../qtnetwork/qtcpsocket.html">QTcpSocket</a></span> sock;
  sock<span class="operator">.</span>connectToHost(url<span class="operator">.</span>host()<span class="operator">,</span> url<span class="operator">.</span>port(<span class="number">80</span>));

</pre>
<p>This function was introduced in  Qt 4.1.</p>
<p><b>See also </b><a href="qurl.html#setPort">setPort</a>().</p>
<!-- @@@port -->
<!-- $$$query[overload1]$$$queryQUrl::ComponentFormattingOptions -->
<h3 class="fn" id="query"><a name="query"></a><span class="type"><a href="qstring.html">QString</a></span> QUrl::<span class="name">query</span>(<span class="type"><a href="qurl.html#ComponentFormattingOption-enum">QUrl::ComponentFormattingOptions</a></span> <i>options</i> = PrettyDecoded) const</h3>
<p>Returns the query string of the URL if there's a query string, or an empty result if not. To determine if the parsed URL contained a query string, use <a href="qurl.html#hasQuery">hasQuery</a>().</p>
<p>The <i>options</i> argument controls how to format the query component. All values produce an unambiguous result. With <a href="qurl.html#ComponentFormattingOption-enum">QUrl::FullyDecoded</a>, all percent-encoded sequences are decoded; otherwise, the returned value may contain some percent-encoded sequences for some control sequences not representable in decoded form in <a href="qstring.html">QString</a>.</p>
<p>Note that use of <a href="qurl.html#ComponentFormattingOption-enum">QUrl::FullyDecoded</a> in queries is discouraged, as queries often contain data that is supposed to remain percent-encoded, including the use of the &quot;%2B&quot; sequence to represent a plus character ('+').</p>
<p><b>See also </b><a href="qurl.html#setQuery">setQuery</a>() and <a href="qurl.html#hasQuery">hasQuery</a>().</p>
<!-- @@@query -->
<!-- $$$resolved[overload1]$$$resolvedconstQUrl& -->
<h3 class="fn" id="resolved"><a name="resolved"></a><span class="type"><a href="qurl.html#QUrl">QUrl</a></span> QUrl::<span class="name">resolved</span>(const <span class="type"><a href="qurl.html#QUrl">QUrl</a></span> &amp;<i>relative</i>) const</h3>
<p>Returns the result of the merge of this URL with <i>relative</i>. This URL is used as a base to convert <i>relative</i> to an absolute URL.</p>
<p>If <i>relative</i> is not a relative URL, this function will return <i>relative</i> directly. Otherwise, the paths of the two URLs are merged, and the new URL returned has the scheme and authority of the base URL, but with the merged path, as in the following example:</p>
<pre class="cpp">

  <span class="type"><a href="qurl.html#QUrl">QUrl</a></span> baseUrl(<span class="string">&quot;http://qt.digia.com/Support/&quot;</span>);
  <span class="type"><a href="qurl.html#QUrl">QUrl</a></span> relativeUrl(<span class="string">&quot;../Product/Library/&quot;</span>);
  <a href="qtglobal.html#qDebug">qDebug</a>(baseUrl<span class="operator">.</span>resolved(relativeUrl)<span class="operator">.</span>toString());
  <span class="comment">// prints &quot;http://qt.digia.com/Product/Library/&quot;</span>

</pre>
<p>Calling resolved() with &quot;..&quot; returns a <a href="qurl.html">QUrl</a> whose directory is one level higher than the original. Similarly, calling resolved() with &quot;../&#x2e;.&quot; removes two levels from the path. If <i>relative</i> is &quot;/&quot;, the path becomes &quot;/&quot;.</p>
<p><b>See also </b><a href="qurl.html#isRelative">isRelative</a>().</p>
<!-- @@@resolved -->
<!-- $$$scheme[overload1]$$$scheme -->
<h3 class="fn" id="scheme"><a name="scheme"></a><span class="type"><a href="qstring.html">QString</a></span> QUrl::<span class="name">scheme</span>() const</h3>
<p>Returns the scheme of the URL. If an empty string is returned, this means the scheme is undefined and the URL is then relative.</p>
<p>The scheme can only contain US-ASCII letters or digits, which means it cannot contain any character that would otherwise require encoding. Additionally, schemes are always returned in lowercase form.</p>
<p><b>See also </b><a href="qurl.html#setScheme">setScheme</a>() and <a href="qurl.html#isRelative">isRelative</a>().</p>
<!-- @@@scheme -->
<!-- $$$setAuthority[overload1]$$$setAuthorityconstQString&QUrl::ParsingMode -->
<h3 class="fn" id="setAuthority"><a name="setAuthority"></a><span class="type">void</span> QUrl::<span class="name">setAuthority</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>authority</i>, <span class="type"><a href="qurl.html#ParsingMode-enum">QUrl::ParsingMode</a></span> <i>mode</i> = TolerantMode)</h3>
<p>Sets the authority of the URL to <i>authority</i>.</p>
<p>The authority of a URL is the combination of user info, a host name and a port. All of these elements are optional; an empty authority is therefore valid.</p>
<p>The user info and host are separated by a '@', and the host and port are separated by a ':'. If the user info is empty, the '@' must be omitted; although a stray ':' is permitted if the port is empty.</p>
<p>The following example shows a valid authority string:</p>
<p class="centerAlign"><img src="images/qurl-authority.png" alt="" /></p><p>The <i>authority</i> data is interpreted according to <i>mode</i>: in <a href="qurl.html#ParsingMode-enum">StrictMode</a>, any '%' characters must be followed by exactly two hexadecimal characters and some characters (including space) are not allowed in undecoded form. In <a href="qurl.html#ParsingMode-enum">TolerantMode</a> (the default), all characters are accepted in undecoded form and the tolerant parser will correct stray '%' not followed by two hex characters.</p>
<p>This function does not allow <i>mode</i> to be <a href="qurl.html#ParsingMode-enum">QUrl::DecodedMode</a>. To set fully decoded data, call <a href="qurl.html#setUserName">setUserName</a>(), <a href="qurl.html#setPassword">setPassword</a>(), <a href="qurl.html#setHost">setHost</a>() and <a href="qurl.html#setPort">setPort</a>() individually.</p>
<p><b>See also </b><a href="qurl.html#authority">authority</a>(), <a href="qurl.html#setUserInfo">setUserInfo</a>(), <a href="qurl.html#setHost">setHost</a>(), and <a href="qurl.html#setPort">setPort</a>().</p>
<!-- @@@setAuthority -->
<!-- $$$setFragment[overload1]$$$setFragmentconstQString&QUrl::ParsingMode -->
<h3 class="fn" id="setFragment"><a name="setFragment"></a><span class="type">void</span> QUrl::<span class="name">setFragment</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>fragment</i>, <span class="type"><a href="qurl.html#ParsingMode-enum">QUrl::ParsingMode</a></span> <i>mode</i> = TolerantMode)</h3>
<p>Sets the fragment of the URL to <i>fragment</i>. The fragment is the last part of the URL, represented by a '#' followed by a string of characters. It is typically used in HTTP for referring to a certain link or point on a page:</p>
<p class="centerAlign"><img src="images/qurl-fragment.png" alt="" /></p><p>The fragment is sometimes also referred to as the URL &quot;reference&quot;.</p>
<p>Passing an argument of QString() (a null <a href="qstring.html">QString</a>) will unset the fragment. Passing an argument of <a href="qstring.html">QString</a>(&quot;&quot;) (an empty but not null <a href="qstring.html">QString</a>) will set the fragment to an empty string (as if the original URL had a lone &quot;#&quot;).</p>
<p>The <i>fragment</i> data is interpreted according to <i>mode</i>: in <a href="qurl.html#ParsingMode-enum">StrictMode</a>, any '%' characters must be followed by exactly two hexadecimal characters and some characters (including space) are not allowed in undecoded form. In <a href="qurl.html#ParsingMode-enum">TolerantMode</a>, all characters are accepted in undecoded form and the tolerant parser will correct stray '%' not followed by two hex characters. In <a href="qurl.html#ParsingMode-enum">DecodedMode</a>, '%' stand for themselves and encoded characters are not possible.</p>
<p><a href="qurl.html#ParsingMode-enum">QUrl::DecodedMode</a> should be used when setting the fragment from a data source which is not a URL or with a fragment obtained by calling <a href="qurl.html#fragment">fragment</a>() with the <a href="qurl.html#ComponentFormattingOption-enum">QUrl::FullyDecoded</a> formatting option.</p>
<p><b>See also </b><a href="qurl.html#fragment">fragment</a>() and <a href="qurl.html#hasFragment">hasFragment</a>().</p>
<!-- @@@setFragment -->
<!-- $$$setHost[overload1]$$$setHostconstQString&QUrl::ParsingMode -->
<h3 class="fn" id="setHost"><a name="setHost"></a><span class="type">void</span> QUrl::<span class="name">setHost</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>host</i>, <span class="type"><a href="qurl.html#ParsingMode-enum">QUrl::ParsingMode</a></span> <i>mode</i> = DecodedMode)</h3>
<p>Sets the host of the URL to <i>host</i>. The host is part of the authority.</p>
<p>The <i>host</i> data is interpreted according to <i>mode</i>: in <a href="qurl.html#ParsingMode-enum">StrictMode</a>, any '%' characters must be followed by exactly two hexadecimal characters and some characters (including space) are not allowed in undecoded form. In <a href="qurl.html#ParsingMode-enum">TolerantMode</a>, all characters are accepted in undecoded form and the tolerant parser will correct stray '%' not followed by two hex characters. In <a href="qurl.html#ParsingMode-enum">DecodedMode</a>, '%' stand for themselves and encoded characters are not possible.</p>
<p>Note that, in all cases, the result of the parsing must be a valid hostname according to STD 3 rules, as modified by the Internationalized Resource Identifiers specification (RFC 3987). Invalid hostnames are not permitted and will cause <a href="qurl.html#isValid">isValid</a>() to become false.</p>
<p><b>See also </b><a href="qurl.html#host">host</a>() and <a href="qurl.html#setAuthority">setAuthority</a>().</p>
<!-- @@@setHost -->
<!-- $$$setIdnWhitelist[overload1]$$$setIdnWhitelistconstQStringList& -->
<h3 class="fn" id="setIdnWhitelist"><a name="setIdnWhitelist"></a><code>[static] </code><span class="type">void</span> QUrl::<span class="name">setIdnWhitelist</span>(const <span class="type"><a href="qstringlist.html">QStringList</a></span> &amp;<i>list</i>)</h3>
<p>Sets the whitelist of Top-Level Domains (TLDs) that are allowed to have non-ASCII characters in domains to the value of <i>list</i>.</p>
<p>Note that if you call this function, you need to do so <i>before</i> you start any threads that might access <a href="qurl.html#idnWhitelist">idnWhitelist</a>().</p>
<p>Qt comes with a default list that contains the Internet top-level domains that have published support for Internationalized Domain Names (IDNs) and rules to guarantee that no deception can happen between similarly-looking characters (such as the Latin lowercase letter <code>'a'</code> and the Cyrillic equivalent, which in most fonts are visually identical).</p>
<p>This list is periodically maintained, as registrars publish new rules.</p>
<p>This function is provided for those who need to manipulate the list, in order to add or remove a TLD. It is not recommended to change its value for purposes other than testing, as it may expose users to security risks.</p>
<p>This function was introduced in  Qt 4.2.</p>
<p><b>See also </b><a href="qurl.html#idnWhitelist">idnWhitelist</a>().</p>
<!-- @@@setIdnWhitelist -->
<!-- $$$setPassword[overload1]$$$setPasswordconstQString&QUrl::ParsingMode -->
<h3 class="fn" id="setPassword"><a name="setPassword"></a><span class="type">void</span> QUrl::<span class="name">setPassword</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>password</i>, <span class="type"><a href="qurl.html#ParsingMode-enum">QUrl::ParsingMode</a></span> <i>mode</i> = DecodedMode)</h3>
<p>Sets the URL's password to <i>password</i>. The <i>password</i> is part of the user info element in the authority of the URL, as described in <a href="qurl.html#setUserInfo">setUserInfo</a>().</p>
<p>The <i>password</i> data is interpreted according to <i>mode</i>: in <a href="qurl.html#ParsingMode-enum">StrictMode</a>, any '%' characters must be followed by exactly two hexadecimal characters and some characters (including space) are not allowed in undecoded form. In <a href="qurl.html#ParsingMode-enum">TolerantMode</a>, all characters are accepted in undecoded form and the tolerant parser will correct stray '%' not followed by two hex characters. In <a href="qurl.html#ParsingMode-enum">DecodedMode</a>, '%' stand for themselves and encoded characters are not possible.</p>
<p><a href="qurl.html#ParsingMode-enum">QUrl::DecodedMode</a> should be used when setting the password from a data source which is not a URL, such as a password dialog shown to the user or with a password obtained by calling <a href="qurl.html#password">password</a>() with the <a href="qurl.html#ComponentFormattingOption-enum">QUrl::FullyDecoded</a> formatting option.</p>
<p><b>See also </b><a href="qurl.html#password">password</a>() and <a href="qurl.html#setUserInfo">setUserInfo</a>().</p>
<!-- @@@setPassword -->
<!-- $$$setPath[overload1]$$$setPathconstQString&QUrl::ParsingMode -->
<h3 class="fn" id="setPath"><a name="setPath"></a><span class="type">void</span> QUrl::<span class="name">setPath</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>path</i>, <span class="type"><a href="qurl.html#ParsingMode-enum">QUrl::ParsingMode</a></span> <i>mode</i> = DecodedMode)</h3>
<p>Sets the path of the URL to <i>path</i>. The path is the part of the URL that comes after the authority but before the query string.</p>
<p class="centerAlign"><img src="images/qurl-ftppath.png" alt="" /></p><p>For non-hierarchical schemes, the path will be everything following the scheme declaration, as in the following example:</p>
<p class="centerAlign"><img src="images/qurl-mailtopath.png" alt="" /></p><p>The <i>path</i> data is interpreted according to <i>mode</i>: in <a href="qurl.html#ParsingMode-enum">StrictMode</a>, any '%' characters must be followed by exactly two hexadecimal characters and some characters (including space) are not allowed in undecoded form. In <a href="qurl.html#ParsingMode-enum">TolerantMode</a>, all characters are accepted in undecoded form and the tolerant parser will correct stray '%' not followed by two hex characters. In <a href="qurl.html#ParsingMode-enum">DecodedMode</a>, '%' stand for themselves and encoded characters are not possible.</p>
<p><a href="qurl.html#ParsingMode-enum">QUrl::DecodedMode</a> should be used when setting the path from a data source which is not a URL, such as a dialog shown to the user or with a path obtained by calling <a href="qurl.html#path">path</a>() with the <a href="qurl.html#ComponentFormattingOption-enum">QUrl::FullyDecoded</a> formatting option.</p>
<p><b>See also </b><a href="qurl.html#path">path</a>().</p>
<!-- @@@setPath -->
<!-- $$$setPort[overload1]$$$setPortint -->
<h3 class="fn" id="setPort"><a name="setPort"></a><span class="type">void</span> QUrl::<span class="name">setPort</span>(<span class="type">int</span> <i>port</i>)</h3>
<p>Sets the port of the URL to <i>port</i>. The port is part of the authority of the URL, as described in <a href="qurl.html#setAuthority">setAuthority</a>().</p>
<p><i>port</i> must be between 0 and 65535 inclusive. Setting the port to -1 indicates that the port is unspecified.</p>
<p><b>See also </b><a href="qurl.html#port">port</a>().</p>
<!-- @@@setPort -->
<!-- $$$setQuery[overload1]$$$setQueryconstQString&QUrl::ParsingMode -->
<h3 class="fn" id="setQuery"><a name="setQuery"></a><span class="type">void</span> QUrl::<span class="name">setQuery</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>query</i>, <span class="type"><a href="qurl.html#ParsingMode-enum">QUrl::ParsingMode</a></span> <i>mode</i> = TolerantMode)</h3>
<p>Sets the query string of the URL to <i>query</i>.</p>
<p>This function is useful if you need to pass a query string that does not fit into the key-value pattern, or that uses a different scheme for encoding special characters than what is suggested by <a href="qurl.html">QUrl</a>.</p>
<p>Passing a value of QString() to <i>query</i> (a null <a href="qstring.html">QString</a>) unsets the query completely. However, passing a value of <a href="qstring.html">QString</a>(&quot;&quot;) will set the query to an empty value, as if the original URL had a lone &quot;?&quot;.</p>
<p>The <i>query</i> data is interpreted according to <i>mode</i>: in <a href="qurl.html#ParsingMode-enum">StrictMode</a>, any '%' characters must be followed by exactly two hexadecimal characters and some characters (including space) are not allowed in undecoded form. In <a href="qurl.html#ParsingMode-enum">TolerantMode</a>, all characters are accepted in undecoded form and the tolerant parser will correct stray '%' not followed by two hex characters. In <a href="qurl.html#ParsingMode-enum">DecodedMode</a>, '%' stand for themselves and encoded characters are not possible.</p>
<p>Query strings often contain percent-encoded sequences, so use of <a href="qurl.html#ParsingMode-enum">DecodedMode</a> is discouraged. One special sequence to be aware of is that of the plus character ('+'). <a href="qurl.html">QUrl</a> does not convert spaces to plus characters, even though HTML forms posted by web browsers do. In order to represent an actual plus character in a query, the sequence &quot;%2B&quot; is usually used. This function will leave &quot;%2B&quot; sequences untouched in <a href="qurl.html#ParsingMode-enum">TolerantMode</a> or <a href="qurl.html#ParsingMode-enum">StrictMode</a>.</p>
<p><b>See also </b><a href="qurl.html#query">query</a>() and <a href="qurl.html#hasQuery">hasQuery</a>().</p>
<!-- @@@setQuery -->
<!-- $$$setQuery$$$setQueryconstQUrlQuery& -->
<h3 class="fn" id="setQuery-1"><a name="setQuery-1"></a><span class="type">void</span> QUrl::<span class="name">setQuery</span>(const <span class="type"><a href="qurlquery.html">QUrlQuery</a></span> &amp;<i>query</i>)</h3>
<p>This is an overloaded function.</p>
<p>Sets the query string of the URL to <i>query</i>.</p>
<p>This function reconstructs the query string from the <a href="qurlquery.html">QUrlQuery</a> object and sets on this <a href="qurl.html">QUrl</a> object. This function does not have parsing parameters because the <a href="qurlquery.html">QUrlQuery</a> contains data that is already parsed.</p>
<p>This function was introduced in  Qt 5.0.</p>
<p><b>See also </b><a href="qurl.html#query">query</a>() and <a href="qurl.html#hasQuery">hasQuery</a>().</p>
<!-- @@@setQuery -->
<!-- $$$setScheme[overload1]$$$setSchemeconstQString& -->
<h3 class="fn" id="setScheme"><a name="setScheme"></a><span class="type">void</span> QUrl::<span class="name">setScheme</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>scheme</i>)</h3>
<p>Sets the scheme of the URL to <i>scheme</i>. As a scheme can only contain ASCII characters, no conversion or decoding is done on the input. It must also start with an ASCII letter.</p>
<p>The scheme describes the type (or protocol) of the URL. It's represented by one or more ASCII characters at the start the URL.</p>
<p>A scheme is strictly <a href="http://www.ietf.org/rfc/rfc3986.txt">RFC 3986</a>-compliant: <code>scheme = ALPHA *( ALPHA / DIGIT / &quot;+&quot; / &quot;-&quot; / &quot;.&quot; )</code></p>
<p>The following example shows a URL where the scheme is &quot;ftp&quot;:</p>
<p class="centerAlign"><img src="images/qurl-authority2.png" alt="" /></p><p>To set the scheme, the following call is used:</p>
<pre class="cpp">

      <span class="type"><a href="qurl.html#QUrl">QUrl</a></span> url;
      url<span class="operator">.</span>setScheme(<span class="string">&quot;ftp&quot;</span>);

</pre>
<p>The scheme can also be empty, in which case the URL is interpreted as relative.</p>
<p><b>See also </b><a href="qurl.html#scheme">scheme</a>() and <a href="qurl.html#isRelative">isRelative</a>().</p>
<!-- @@@setScheme -->
<!-- $$$setUrl[overload1]$$$setUrlconstQString&QUrl::ParsingMode -->
<h3 class="fn" id="setUrl"><a name="setUrl"></a><span class="type">void</span> QUrl::<span class="name">setUrl</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>url</i>, <span class="type"><a href="qurl.html#ParsingMode-enum">QUrl::ParsingMode</a></span> <i>parsingMode</i> = TolerantMode)</h3>
<p>Parses <i>url</i> and sets this object to that value. <a href="qurl.html">QUrl</a> will automatically percent encode all characters that are not allowed in a URL and decode the percent-encoded sequences that represent an unreserved character (letters, digits, hyphens, undercores, dots and tildes). All other characters are left in their original forms.</p>
<p>Parses the <i>url</i> using the parser mode <i>parsingMode</i>. In <a href="qurl.html#ParsingMode-enum">TolerantMode</a> (the default), <a href="qurl.html">QUrl</a> will correct certain mistakes, notably the presence of a percent character ('%') not followed by two hexadecimal digits, and it will accept any character in any position. In <a href="qurl.html#ParsingMode-enum">StrictMode</a>, encoding mistakes will not be tolerated and <a href="qurl.html">QUrl</a> will also check that certain forbidden characters are not present in unencoded form. If an error is detected in <a href="qurl.html#ParsingMode-enum">StrictMode</a>, <a href="qurl.html#isValid">isValid</a>() will return false. The parsing mode <a href="qurl.html#ParsingMode-enum">DecodedMode</a> is not permitted in this context and will produce a run-time warning.</p>
<p><b>See also </b><a href="qurl.html#url">url</a>() and <a href="qurl.html#toString">toString</a>().</p>
<!-- @@@setUrl -->
<!-- $$$setUserInfo[overload1]$$$setUserInfoconstQString&QUrl::ParsingMode -->
<h3 class="fn" id="setUserInfo"><a name="setUserInfo"></a><span class="type">void</span> QUrl::<span class="name">setUserInfo</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>userInfo</i>, <span class="type"><a href="qurl.html#ParsingMode-enum">QUrl::ParsingMode</a></span> <i>mode</i> = TolerantMode)</h3>
<p>Sets the user info of the URL to <i>userInfo</i>. The user info is an optional part of the authority of the URL, as described in <a href="qurl.html#setAuthority">setAuthority</a>().</p>
<p>The user info consists of a user name and optionally a password, separated by a ':'. If the password is empty, the colon must be omitted. The following example shows a valid user info string:</p>
<p class="centerAlign"><img src="images/qurl-authority3.png" alt="" /></p><p>The <i>userInfo</i> data is interpreted according to <i>mode</i>: in <a href="qurl.html#ParsingMode-enum">StrictMode</a>, any '%' characters must be followed by exactly two hexadecimal characters and some characters (including space) are not allowed in undecoded form. In <a href="qurl.html#ParsingMode-enum">TolerantMode</a> (the default), all characters are accepted in undecoded form and the tolerant parser will correct stray '%' not followed by two hex characters.</p>
<p>This function does not allow <i>mode</i> to be <a href="qurl.html#ParsingMode-enum">QUrl::DecodedMode</a>. To set fully decoded data, call <a href="qurl.html#setUserName">setUserName</a>() and <a href="qurl.html#setPassword">setPassword</a>() individually.</p>
<p><b>See also </b><a href="qurl.html#userInfo">userInfo</a>(), <a href="qurl.html#setUserName">setUserName</a>(), <a href="qurl.html#setPassword">setPassword</a>(), and <a href="qurl.html#setAuthority">setAuthority</a>().</p>
<!-- @@@setUserInfo -->
<!-- $$$setUserName[overload1]$$$setUserNameconstQString&QUrl::ParsingMode -->
<h3 class="fn" id="setUserName"><a name="setUserName"></a><span class="type">void</span> QUrl::<span class="name">setUserName</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>userName</i>, <span class="type"><a href="qurl.html#ParsingMode-enum">QUrl::ParsingMode</a></span> <i>mode</i> = DecodedMode)</h3>
<p>Sets the URL's user name to <i>userName</i>. The <i>userName</i> is part of the user info element in the authority of the URL, as described in <a href="qurl.html#setUserInfo">setUserInfo</a>().</p>
<p>The <i>userName</i> data is interpreted according to <i>mode</i>: in <a href="qurl.html#ParsingMode-enum">StrictMode</a>, any '%' characters must be followed by exactly two hexadecimal characters and some characters (including space) are not allowed in undecoded form. In <a href="qurl.html#ParsingMode-enum">TolerantMode</a> (the default), all characters are accepted in undecoded form and the tolerant parser will correct stray '%' not followed by two hex characters. In <a href="qurl.html#ParsingMode-enum">DecodedMode</a>, '%' stand for themselves and encoded characters are not possible.</p>
<p><a href="qurl.html#ParsingMode-enum">QUrl::DecodedMode</a> should be used when setting the user name from a data source which is not a URL, such as a password dialog shown to the user or with a user name obtained by calling <a href="qurl.html#userName">userName</a>() with the <a href="qurl.html#ComponentFormattingOption-enum">QUrl::FullyDecoded</a> formatting option.</p>
<p><b>See also </b><a href="qurl.html#userName">userName</a>() and <a href="qurl.html#setUserInfo">setUserInfo</a>().</p>
<!-- @@@setUserName -->
<!-- $$$swap[overload1]$$$swapQUrl& -->
<h3 class="fn" id="swap"><a name="swap"></a><span class="type">void</span> QUrl::<span class="name">swap</span>(<span class="type"><a href="qurl.html#QUrl">QUrl</a></span> &amp;<i>other</i>)</h3>
<p>Swaps URL <i>other</i> with this URL. This operation is very fast and never fails.</p>
<p>This function was introduced in  Qt 4.8.</p>
<!-- @@@swap -->
<!-- $$$toAce[overload1]$$$toAceconstQString& -->
<h3 class="fn" id="toAce"><a name="toAce"></a><code>[static] </code><span class="type"><a href="qbytearray.html">QByteArray</a></span> QUrl::<span class="name">toAce</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>domain</i>)</h3>
<p>Returns the ASCII Compatible Encoding of the given domain name <i>domain</i>. The result of this function is considered equivalent to <i>domain</i>.</p>
<p>The ASCII-Compatible Encoding (ACE) is defined by RFC 3490, RFC 3491 and RFC 3492. It is part of the Internationalizing Domain Names in Applications (IDNA) specification, which allows for domain names (like <code>&quot;example.com&quot;</code>) to be written using international characters.</p>
<p>This function returns an empty <a href="qbytearray.html">QByteArray</a> if <i>domain</i> is not a valid hostname. Note, in particular, that IPv6 literals are not valid domain names.</p>
<p>This function was introduced in  Qt 4.2.</p>
<!-- @@@toAce -->
<!-- $$$toCFURL[overload1]$$$toCFURL -->
<h3 class="fn" id="toCFURL"><a name="toCFURL"></a><span class="type">CFURLRef</span> QUrl::<span class="name">toCFURL</span>() const</h3>
<p>Creates a CFURL from a <a href="qurl.html">QUrl</a>. The caller owns the CFURL and is responsible for releasing it.</p>
<p>This function was introduced in  Qt 5.2.</p>
<!-- @@@toCFURL -->
<!-- $$$toDisplayString[overload1]$$$toDisplayStringQUrl::FormattingOptions -->
<h3 class="fn" id="toDisplayString"><a name="toDisplayString"></a><span class="type"><a href="qstring.html">QString</a></span> QUrl::<span class="name">toDisplayString</span>(<span class="type"><a href="qurl.html#UrlFormattingOption-enum">QUrl::FormattingOptions</a></span> <i>options</i> = FormattingOptions(PrettyDecoded)) const</h3>
<p>Returns a human-displayable string representation of the URL. The output can be customized by passing flags with <i>options</i>. The option <a href="qurl.html#UrlFormattingOption-enum">RemovePassword</a> is always enabled, since passwords should never be shown back to users.</p>
<p>With the default options, the resulting <a href="qstring.html">QString</a> can be passed back to a <a href="qurl.html">QUrl</a> later on, but any password that was present initially will be lost.</p>
<p>This function was introduced in  Qt 5.0.</p>
<p><b>See also </b><a href="qurl.html#UrlFormattingOption-enum">FormattingOptions</a>, <a href="qurl.html#toEncoded">toEncoded</a>(), and <a href="qurl.html#toString">toString</a>().</p>
<!-- @@@toDisplayString -->
<!-- $$$toEncoded[overload1]$$$toEncodedQUrl::FormattingOptions -->
<h3 class="fn" id="toEncoded"><a name="toEncoded"></a><span class="type"><a href="qbytearray.html">QByteArray</a></span> QUrl::<span class="name">toEncoded</span>(<span class="type"><a href="qurl.html#UrlFormattingOption-enum">QUrl::FormattingOptions</a></span> <i>options</i> = FullyEncoded) const</h3>
<p>Returns the encoded representation of the URL if it's valid; otherwise an empty <a href="qbytearray.html">QByteArray</a> is returned. The output can be customized by passing flags with <i>options</i>.</p>
<p>The user info, path and fragment are all converted to UTF-8, and all non-ASCII characters are then percent encoded. The host name is encoded using Punycode.</p>
<!-- @@@toEncoded -->
<!-- $$$toLocalFile[overload1]$$$toLocalFile -->
<h3 class="fn" id="toLocalFile"><a name="toLocalFile"></a><span class="type"><a href="qstring.html">QString</a></span> QUrl::<span class="name">toLocalFile</span>() const</h3>
<p>Returns the path of this URL formatted as a local file path. The path returned will use forward slashes, even if it was originally created from one with backslashes.</p>
<p>If this URL contains a non-empty hostname, it will be encoded in the returned value in the form found on SMB networks (for example, &quot;//servername/path/to/file.txt&quot;).</p>
<pre class="cpp">

      <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="type"><a href="qurl.html#QUrl">QUrl</a></span>(<span class="string">&quot;file:file.txt&quot;</span>)<span class="operator">.</span>toLocalFile();            <span class="comment">// &quot;file:file.txt&quot;</span>
      <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="type"><a href="qurl.html#QUrl">QUrl</a></span>(<span class="string">&quot;file:/home/user/file.txt&quot;</span>)<span class="operator">.</span>toLocalFile(); <span class="comment">// &quot;file:///home/user/file.txt&quot;</span>
      <a href="qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="type"><a href="qurl.html#QUrl">QUrl</a></span>(<span class="string">&quot;file.txt&quot;</span>)<span class="operator">.</span>toLocalFile();                 <span class="comment">// &quot;&quot;; wasn't a local file as it had no scheme</span>

</pre>
<p>Note: if the path component of this URL contains a non-UTF-8 binary sequence (such as %80), the behaviour of this function is undefined.</p>
<p><b>See also </b><a href="qurl.html#fromLocalFile">fromLocalFile</a>() and <a href="qurl.html#isLocalFile">isLocalFile</a>().</p>
<!-- @@@toLocalFile -->
<!-- $$$toNSURL[overload1]$$$toNSURL -->
<h3 class="fn" id="toNSURL"><a name="toNSURL"></a><span class="type">NSURL</span> *QUrl::<span class="name">toNSURL</span>() const</h3>
<p>Creates a NSURL from a <a href="qurl.html">QUrl</a>. The NSURL is autoreleased.</p>
<p>This function was introduced in  Qt 5.2.</p>
<!-- @@@toNSURL -->
<!-- $$$toPercentEncoding[overload1]$$$toPercentEncodingconstQString&constQByteArray&constQByteArray& -->
<h3 class="fn" id="toPercentEncoding"><a name="toPercentEncoding"></a><code>[static] </code><span class="type"><a href="qbytearray.html">QByteArray</a></span> QUrl::<span class="name">toPercentEncoding</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>input</i>, const <span class="type"><a href="qbytearray.html">QByteArray</a></span> &amp;<i>exclude</i> = QByteArray(), const <span class="type"><a href="qbytearray.html">QByteArray</a></span> &amp;<i>include</i> = QByteArray())</h3>
<p>Returns an encoded copy of <i>input</i>. <i>input</i> is first converted to UTF-8, and all ASCII-characters that are not in the unreserved group are percent encoded. To prevent characters from being percent encoded pass them to <i>exclude</i>. To force characters to be percent encoded pass them to <i>include</i>.</p>
<p>Unreserved is defined as: <code>ALPHA / DIGIT / &quot;-&quot; / &quot;.&quot; / &quot;_&quot; / &quot;~&quot;</code></p>
<pre class="cpp">

  <span class="type"><a href="qbytearray.html">QByteArray</a></span> ba <span class="operator">=</span> <span class="type"><a href="qurl.html#QUrl">QUrl</a></span><span class="operator">::</span>toPercentEncoding(<span class="string">&quot;{a fishy string?}&quot;</span><span class="operator">,</span> <span class="string">&quot;{}&quot;</span><span class="operator">,</span> <span class="string">&quot;s&quot;</span>);
  <a href="qtglobal.html#qDebug">qDebug</a>(ba<span class="operator">.</span>constData());
  <span class="comment">// prints &quot;{a fi%73hy %73tring%3F}&quot;</span>

</pre>
<!-- @@@toPercentEncoding -->
<!-- $$$toString[overload1]$$$toStringQUrl::FormattingOptions -->
<h3 class="fn" id="toString"><a name="toString"></a><span class="type"><a href="qstring.html">QString</a></span> QUrl::<span class="name">toString</span>(<span class="type"><a href="qurl.html#UrlFormattingOption-enum">QUrl::FormattingOptions</a></span> <i>options</i> = FormattingOptions(PrettyDecoded)) const</h3>
<p>Returns a string representation of the URL. The output can be customized by passing flags with <i>options</i>. The option <a href="qurl.html#ComponentFormattingOption-enum">QUrl::FullyDecoded</a> is not permitted in this function since it would generate ambiguous data.</p>
<p>The default formatting option is <a href="qurl.html#UrlFormattingOption-enum">PrettyDecoded</a>.</p>
<p><b>See also </b><a href="qurl.html#UrlFormattingOption-enum">FormattingOptions</a>, <a href="qurl.html#url">url</a>(), and <a href="qurl.html#setUrl">setUrl</a>().</p>
<!-- @@@toString -->
<!-- $$$toStringList[overload1]$$$toStringListconstQList<QUrl>&QUrl::FormattingOptions -->
<h3 class="fn" id="toStringList"><a name="toStringList"></a><code>[static] </code><span class="type"><a href="qstringlist.html">QStringList</a></span> QUrl::<span class="name">toStringList</span>(const <span class="type"><a href="qlist.html">QList</a></span>&lt;<span class="type"><a href="qurl.html#QUrl">QUrl</a></span>&gt; &amp;<i>urls</i>, <span class="type"><a href="qurl.html#UrlFormattingOption-enum">QUrl::FormattingOptions</a></span> <i>options</i> = FormattingOptions(PrettyDecoded))</h3>
<p>Converts a list of <i>urls</i> into a list of <a href="qstring.html">QString</a> objects, using <a href="qurl.html#toString">toString</a>(<i>options</i>).</p>
<p>This function was introduced in  Qt 5.1.</p>
<!-- @@@toStringList -->
<!-- $$$topLevelDomain[overload1]$$$topLevelDomainQUrl::ComponentFormattingOptions -->
<h3 class="fn" id="topLevelDomain"><a name="topLevelDomain"></a><span class="type"><a href="qstring.html">QString</a></span> QUrl::<span class="name">topLevelDomain</span>(<span class="type"><a href="qurl.html#ComponentFormattingOption-enum">QUrl::ComponentFormattingOptions</a></span> <i>options</i> = FullyDecoded) const</h3>
<p>Returns the TLD (Top-Level Domain) of the URL, (e.g&#x2e; &#x2e;co.uk, .net). Note that the return value is prefixed with a '.' unless the URL does not contain a valid TLD, in which case the function returns an empty string.</p>
<p>Note that this function considers a TLD to be any domain that allows users to register subdomains under, including many home, dynamic DNS websites and blogging providers. This is useful for determining whether two websites belong to the same infrastructure and communication should be allowed, such as browser cookies: two domains should be considered part of the same website if they share at least one label in addition to the value returned by this function.</p>
<ul>
<li><code>foo.co.uk</code> and <code>foo.com</code> do not share a top-level domain</li>
<li><code>foo.co.uk</code> and <code>bar.co.uk</code> share the <code>.co.uk</code> domain, but the next label is different</li>
<li><code>www.foo.co.uk</code> and <code>ftp.foo.co.uk</code> share the same top-level domain and one more label, so they are considered part of the same site</li>
</ul>
<p>If <i>options</i> includes <a href="qurl.html#ComponentFormattingOption-enum">EncodeUnicode</a>, the returned string will be in ASCII Compatible Encoding.</p>
<p>This function was introduced in  Qt 4.8.</p>
<!-- @@@topLevelDomain -->
<!-- $$$url[overload1]$$$urlQUrl::FormattingOptions -->
<h3 class="fn" id="url"><a name="url"></a><span class="type"><a href="qstring.html">QString</a></span> QUrl::<span class="name">url</span>(<span class="type"><a href="qurl.html#UrlFormattingOption-enum">QUrl::FormattingOptions</a></span> <i>options</i> = FormattingOptions(PrettyDecoded)) const</h3>
<p>Returns a string representation of the URL. The output can be customized by passing flags with <i>options</i>. The option <a href="qurl.html#ComponentFormattingOption-enum">QUrl::FullyDecoded</a> is not permitted in this function since it would generate ambiguous data.</p>
<p>The resulting <a href="qstring.html">QString</a> can be passed back to a <a href="qurl.html">QUrl</a> later on.</p>
<p>Synonym for <a href="qurl.html#toString">toString</a>(options).</p>
<p><b>See also </b><a href="qurl.html#setUrl">setUrl</a>(), <a href="qurl.html#UrlFormattingOption-enum">FormattingOptions</a>, <a href="qurl.html#toEncoded">toEncoded</a>(), and <a href="qurl.html#toString">toString</a>().</p>
<!-- @@@url -->
<!-- $$$userInfo[overload1]$$$userInfoQUrl::ComponentFormattingOptions -->
<h3 class="fn" id="userInfo"><a name="userInfo"></a><span class="type"><a href="qstring.html">QString</a></span> QUrl::<span class="name">userInfo</span>(<span class="type"><a href="qurl.html#ComponentFormattingOption-enum">QUrl::ComponentFormattingOptions</a></span> <i>options</i> = PrettyDecoded) const</h3>
<p>Returns the user info of the URL, or an empty string if the user info is undefined.</p>
<p>This function returns an unambiguous value, which may contain that characters still percent-encoded, plus some control sequences not representable in decoded form in <a href="qstring.html">QString</a>.</p>
<p>The <i>options</i> argument controls how to format the user info component. The value of <a href="qurl.html#ComponentFormattingOption-enum">QUrl::FullyDecoded</a> is not permitted in this function. If you need to obtain fully decoded data, call <a href="qurl.html#userName">userName</a>() and <a href="qurl.html#password">password</a>() individually.</p>
<p><b>See also </b><a href="qurl.html#setUserInfo">setUserInfo</a>(), <a href="qurl.html#userName">userName</a>(), <a href="qurl.html#password">password</a>(), and <a href="qurl.html#authority">authority</a>().</p>
<!-- @@@userInfo -->
<!-- $$$userName[overload1]$$$userNameQUrl::ComponentFormattingOptions -->
<h3 class="fn" id="userName"><a name="userName"></a><span class="type"><a href="qstring.html">QString</a></span> QUrl::<span class="name">userName</span>(<span class="type"><a href="qurl.html#ComponentFormattingOption-enum">QUrl::ComponentFormattingOptions</a></span> <i>options</i> = FullyDecoded) const</h3>
<p>Returns the user name of the URL if it is defined; otherwise an empty string is returned.</p>
<p>The <i>options</i> argument controls how to format the user name component. All values produce an unambiguous result. With <a href="qurl.html#ComponentFormattingOption-enum">QUrl::FullyDecoded</a>, all percent-encoded sequences are decoded; otherwise, the returned value may contain some percent-encoded sequences for some control sequences not representable in decoded form in <a href="qstring.html">QString</a>.</p>
<p>Note that <a href="qurl.html#ComponentFormattingOption-enum">QUrl::FullyDecoded</a> may cause data loss if those non-representable sequences are present. It is recommended to use that value when the result will be used in a non-URL context, such as setting in <a href="../qtnetwork/qauthenticator.html">QAuthenticator</a> or negotiating a login.</p>
<p><b>See also </b><a href="qurl.html#setUserName">setUserName</a>() and <a href="qurl.html#userInfo">userInfo</a>().</p>
<!-- @@@userName -->
<!-- $$$operator!=[overload1]$$$operator!=constQUrl& -->
<h3 class="fn" id="operator-not-eq"><a name="operator-not-eq"></a><span class="type">bool</span> QUrl::<span class="name">operator!=</span>(const <span class="type"><a href="qurl.html#QUrl">QUrl</a></span> &amp;<i>url</i>) const</h3>
<p>Returns <code>true</code> if this URL and the given <i>url</i> are not equal; otherwise returns <code>false</code>.</p>
<!-- @@@operator!= -->
<!-- $$$operator=[overload1]$$$operator=constQUrl& -->
<h3 class="fn" id="operator-eq"><a name="operator-eq"></a><span class="type"><a href="qurl.html#QUrl">QUrl</a></span> &amp;QUrl::<span class="name">operator=</span>(const <span class="type"><a href="qurl.html#QUrl">QUrl</a></span> &amp;<i>url</i>)</h3>
<p>Assigns the specified <i>url</i> to this object.</p>
<!-- @@@operator= -->
<!-- $$$operator=$$$operator=constQString& -->
<h3 class="fn" id="operator-eq-1"><a name="operator-eq-1"></a><span class="type"><a href="qurl.html#QUrl">QUrl</a></span> &amp;QUrl::<span class="name">operator=</span>(const <span class="type"><a href="qstring.html">QString</a></span> &amp;<i>url</i>)</h3>
<p>Assigns the specified <i>url</i> to this object.</p>
<!-- @@@operator= -->
<!-- $$$operator=$$$operator=QUrl&& -->
<h3 class="fn" id="operator-eq-2"><a name="operator-eq-2"></a><span class="type"><a href="qurl.html#QUrl">QUrl</a></span> &amp;QUrl::<span class="name">operator=</span>(<span class="type"><a href="qurl.html#QUrl">QUrl</a></span> &amp;&amp;<i>other</i>)</h3>
<p>Move-assigns <i>other</i> to this <a href="qurl.html">QUrl</a> instance.</p>
<p>This function was introduced in  Qt 5.2.</p>
<!-- @@@operator= -->
<!-- $$$operator==[overload1]$$$operator==constQUrl& -->
<h3 class="fn" id="operator-eq-eq"><a name="operator-eq-eq"></a><span class="type">bool</span> QUrl::<span class="name">operator==</span>(const <span class="type"><a href="qurl.html#QUrl">QUrl</a></span> &amp;<i>url</i>) const</h3>
<p>Returns <code>true</code> if this URL and the given <i>url</i> are equal; otherwise returns <code>false</code>.</p>
<!-- @@@operator== -->
</div>
<div class="relnonmem">
<h2>Related Non-Members</h2>
<!-- $$$operator<<[overload1]$$$operator<<QDataStream&constQUrl& -->
<h3 class="fn" id="operator-lt-lt"><a name="operator-lt-lt"></a><span class="type"><a href="qdatastream.html">QDataStream</a></span> &amp;<span class="name">operator&lt;&lt;</span>(<span class="type"><a href="qdatastream.html">QDataStream</a></span> &amp;<i>out</i>, const <span class="type"><a href="qurl.html#QUrl">QUrl</a></span> &amp;<i>url</i>)</h3>
<p>Writes url <i>url</i> to the stream <i>out</i> and returns a reference to the stream.</p>
<p><b>See also </b><a href="datastreamformat.html">Format of the QDataStream operators</a>.</p>
<!-- @@@operator<< -->
<!-- $$$operator>>[overload1]$$$operator>>QDataStream&QUrl& -->
<h3 class="fn" id="operator-gt-gt"><a name="operator-gt-gt"></a><span class="type"><a href="qdatastream.html">QDataStream</a></span> &amp;<span class="name">operator&gt;&gt;</span>(<span class="type"><a href="qdatastream.html">QDataStream</a></span> &amp;<i>in</i>, <span class="type"><a href="qurl.html#QUrl">QUrl</a></span> &amp;<i>url</i>)</h3>
<p>Reads a url into <i>url</i> from the stream <i>in</i> and returns a reference to the stream.</p>
<p><b>See also </b><a href="datastreamformat.html">Format of the QDataStream operators</a>.</p>
<!-- @@@operator>> -->
</div>
<div class="macros">
<h2>Macro Documentation</h2>
<!-- $$$QT_NO_URL_CAST_FROM_STRING[overload1]$$$QT_NO_URL_CAST_FROM_STRING -->
<h3 class="fn" id="QT_NO_URL_CAST_FROM_STRING"><a name="QT_NO_URL_CAST_FROM_STRING"></a><span class="name">QT_NO_URL_CAST_FROM_STRING</span></h3>
<p>Disables automatic conversions from <a href="qstring.html">QString</a> (or char *) to <a href="qurl.html">QUrl</a>.</p>
<p>Compiling your code with this define is useful when you have a lot of code that uses <a href="qstring.html">QString</a> for file names and you wish to convert it to use <a href="qurl.html">QUrl</a> for network transparency. In any code that uses <a href="qurl.html">QUrl</a>, it can help avoid missing <a href="qurl.html#resolved">QUrl::resolved</a>() calls, and other misuses of <a href="qstring.html">QString</a> to <a href="qurl.html">QUrl</a> conversions.</p>
<p>For example, if you have code like</p>
<pre class="cpp plain">

  url = filename; // probably not what you want

</pre>
<p>you can rewrite it as</p>
<pre class="cpp">

  url <span class="operator">=</span> <span class="type"><a href="qurl.html">QUrl</a></span><span class="operator">::</span>fromLocalFile(filename);
  url <span class="operator">=</span> baseurl<span class="operator">.</span>resolved(<span class="type"><a href="qurl.html">QUrl</a></span>(filename));

</pre>
<p><b>See also </b><a href="qstring.html#QT_NO_CAST_FROM_ASCII">QT_NO_CAST_FROM_ASCII</a>.</p>
<!-- @@@QT_NO_URL_CAST_FROM_STRING -->
</div>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2019 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    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.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>