/usr/share/qt5/doc/qtqml/qml-url.html is in qtdeclarative5-doc-html 5.5.1-2ubuntu6.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 | <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- basictypes.qdoc -->
<title>url QML Basic Type | Qt QML 5.5</title>
<link rel="stylesheet" type="text/css" href="style/offline.css" />
</head>
<body>
<div class="header" id="qtdocheader">
<div class="main">
<div class="main-rounded">
<div class="navigationbar">
<ul>
<li>Qt 5.5</li>
<li><a href="qtqml-index.html">Qt QML</a></li>
<li><a href="qtqml-qmlmodule.html">QML Types</a></li>
<li>url QML Basic Type</li>
<li id="buildversion">Qt 5.5.1 Reference Documentation</li>
</ul>
</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="#using-the-url-type">Using the url Type</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">url QML Basic Type</h1>
<span class="subtitle"></span>
<!-- $$$url-description -->
<div class="descr"> <a name="details"></a>
<p>a resource locator.</p>
<p>The <code>url</code> type refers to a resource locator (like a file name, for example). It can be either absolute, e.g. "http://qt-project.org", or relative, e.g. "pics/logo.png". A relative URL is resolved relative to the URL of the containing component.</p>
<p>For example, the following assigns a valid URL to the Image::source property, which is of type <code>url</code>:</p>
<pre class="qml"><span class="type">Image</span> { <span class="name">source</span>: <span class="string">"pics/logo.png"</span> }</pre>
<p>When integrating with C++, note that any QUrl value <a href="qtqml-cppintegration-data.html">passed into QML from C++</a> is automatically converted into a <code>url</code> value, and vice-versa.</p>
<a name="using-the-url-type"></a>
<h2 id="using-the-url-type">Using the url Type</h2>
<p>When a relative URL is written to a <code>url</code> type property, it is converted into a URL object, so <b>matching the URL value against the input string value will fail</b>. Instead, convert the string to a URL using Qt.resolvedUrl() for means of comparison, and use <code>toString()</code> to get the contents of the URL:</p>
<pre class="qml"><span class="type">Image</span> {
<span class="name">source</span>: <span class="string">"pics/logo.png"</span>
<span class="name">Component</span>.onCompleted: {
<span class="comment">// This prints 'false'. Although "pics/logo.png" was the input string,</span>
<span class="comment">// it's been converted from a string to a URL, so these two are not the same.</span>
<span class="name">console</span>.<span class="name">log</span>(<span class="name">source</span> <span class="operator">==</span> <span class="string">"pics/logo.png"</span>)
<span class="comment">// This prints 'true' as Qt.resovledUrl() converts the string into a</span>
<span class="comment">// URL with the correctly resolved path</span>
<span class="name">console</span>.<span class="name">log</span>(<span class="name">source</span> <span class="operator">==</span> <span class="name">Qt</span>.<span class="name">resolvedUrl</span>(<span class="string">"pics/logo.png"</span>))
<span class="comment">// This prints the absolute path, e.g. "file:///path/to/pics/logo.png"</span>
<span class="name">console</span>.<span class="name">log</span>(<span class="name">source</span>.<span class="name">toString</span>())
}
}</pre>
<p><b>Note: </b>When referring to files stored with the Qt Resource System from within QML, you should use "qrc:///" instead of ":/" as QML requires URL paths. Relative URLs resolved from within that file will use the same protocol.</p><p>Additionally, URLs may contain encoded characters using the 'percent-encoding' scheme specified by <a href="http://tools.ietf.org/html/rfc3986">RFC 3986</a>. These characters will be preserved within properties of type <code>url</code>, to allow QML code to construct precise URL values. An exception to this rule is the preemptive decoding of directory-separator characters (<code>'/'</code>) - these characters are decoded to allow the URL to be correctly classified.</p>
<p>For example, a local file containing a '#' character, which would normally be interpreted as the beginning of the URL 'fragment' element, can be accessed by encoding the characters of the file name:</p>
<pre class="qml"><span class="type">Image</span> { <span class="name">source</span>: <span class="name">encodeURIComponent</span>(<span class="string">"/tmp/test#1.png"</span>) }</pre>
<p>This basic type is provided by the QML language.</p>
</div>
<p><b>See also </b><a href="qtqml-typesystem-basictypes.html">QML Basic Types</a>.</p>
<!-- @@@url -->
</div>
</div>
</div>
</div>
</div>
<div class="footer">
<p>
<acronym title="Copyright">©</acronym> 2015 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>
|