/usr/share/qt5/doc/qtbluetooth/qtbluetooth-picturetransfer-example.html is in qtconnectivity5-doc-html 5.7.1~20161021-2.
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 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- picturetransfer.qdoc -->
<title>QML Bluetooth Picture Push Example | Qt Bluetooth 5.7</title>
<link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
<script type="text/javascript">
window.onload = function(){document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");};
</script>
</head>
<body>
<div class="header" id="qtdocheader">
<div class="main">
<div class="main-rounded">
<div class="navigationbar">
<table><tr>
<td >Qt 5.7</td><td ><a href="qtbluetooth-index.html">Qt Bluetooth</a></td><td >QML Bluetooth Picture Push Example</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right">Qt 5.7.1 Reference Documentation</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="#running-the-example">Running the Example</a></li>
<li class="level1"><a href="#device-discovery">Device Discovery</a></li>
<li class="level1"><a href="#file-selection">File Selection</a></li>
<li class="level1"><a href="#root-element">Root Element</a></li>
<li class="level1"><a href="#file-transfer">File Transfer</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">QML Bluetooth Picture Push Example</h1>
<span class="subtitle"></span>
<!-- $$$picturetransfer-description -->
<div class="descr"> <a name="details"></a>
<p>The Bluetooth Picture Push example shows how to use the <a href="qbluetoothtransfermanager.html">QBluetoothTransferManager</a> API. The example transfers a local image to a remote device. Unfortunately this example cannot be used on Android as Qt does not support the Object Push Profile (OPP) on this platform.</p>
<p>On the first user interface page the application scans for remote Bluetooth devices. The user must select the appropriate device to continue:</p>
<p class="centerAlign"><img src="images/opp-example-1.png" alt="" /></p><p>The next page presents a list of image files on the device. The files must be located under <a href="../qtcore/qstandardpaths.html#StandardLocation-enum">QStandardPaths::PicturesLocation</a>}:</p>
<p class="centerAlign"><img src="images/opp-example-2.png" alt="" /></p><p>Once the picture was selected the UI shows the progress of the file transfer:</p>
<p class="centerAlign"><img src="images/opp-example-3.png" alt="" /></p><a name="running-the-example"></a>
<h2 id="running-the-example">Running the Example</h2>
<p>To run the example from Qt Creator, open the <b>Welcome</b> mode and select the example from <b>Examples</b>. For more information, visit Building and Running an Example.</p>
<a name="device-discovery"></a>
<h2 id="device-discovery">Device Discovery</h2>
<p>The device discovery uses the <a href="qml-qtbluetooth-bluetoothdiscoverymodel.html">BluetoothDiscoveryModel</a> to detect the remote devices. Each discovery is displayed as an entry in a list. Once a device was selected the device address is stored in the <code>root</code> element. More details about the <code>root</code> element will follow further below.</p>
<pre class="qml">
<span class="type">ListView</span> {
<span class="name">model</span>: <span class="name">BluetoothDiscoveryModel</span> {
<span class="name">discoveryMode</span>: <span class="name">BluetoothDiscoveryModel</span>.<span class="name">DeviceDiscovery</span>
<span class="name">onErrorChanged</span>: {
<span class="keyword">if</span> (<span class="name">error</span> <span class="operator">==</span> <span class="name">BluetoothDiscoveryModel</span>.<span class="name">NoError</span>)
<span class="keyword">return</span>;
<span class="keyword">if</span> (<span class="name">error</span> <span class="operator">==</span> <span class="name">BluetoothDiscoveryModel</span>.<span class="name">PoweredOffError</span>)
<span class="name">titleLabel</span>.<span class="name">text</span> <span class="operator">=</span> <span class="string">"Bluetooth turned off"</span>;
<span class="keyword">else</span>
<span class="name">titleLabel</span>.<span class="name">text</span> <span class="operator">=</span> <span class="string">"Cannot find devices"</span>;
}
}
<span class="name">delegate</span>: <span class="name">Button</span> {
<span class="name">width</span>: <span class="name">listView</span>.<span class="name">width</span> <span class="operator">+</span> <span class="number">2</span>
<span class="name">text</span>: <span class="name">model</span>.<span class="name">name</span>
<span class="name">onClicked</span>: <span class="name">root</span>.<span class="name">remoteDevice</span> <span class="operator">=</span> <span class="name">model</span>.<span class="name">remoteAddress</span>
}
}
</pre>
<a name="file-selection"></a>
<h2 id="file-selection">File Selection</h2>
<p>The file is selected with the help of FolderListModel. Once again the selected file is stored in the <code>root</code> element:</p>
<pre class="qml">
<span class="name">model</span>: <span class="name">FolderListModel</span> {
<span class="name">folder</span>: <span class="string">"file://"</span><span class="operator">+</span><span class="name">SystemPictureFolder</span>
<span class="name">showDirs</span>: <span class="number">false</span>
}
<span class="name">delegate</span>: <span class="name">Rectangle</span> {
<span class="type">Text</span> {
<span class="name">text</span>: <span class="name">model</span>.<span class="name">fileName</span>
}
<span class="type">MouseArea</span> {
<span class="name">id</span>: <span class="name">mArea</span>
<span class="name">anchors</span>.fill: <span class="name">parent</span>
<span class="name">onClicked</span>: {
<span class="name">print</span> (<span class="string">"path: "</span> <span class="operator">+</span> <span class="name">model</span>.<span class="name">filePath</span> <span class="operator">+</span> <span class="string">" "</span> <span class="operator">+</span> <span class="name">model</span>.<span class="name">fileName</span>)
<span class="name">root</span>.<span class="name">fileName</span> <span class="operator">=</span> <span class="name">model</span>.<span class="name">filePath</span>
}
}
}
</pre>
<a name="root-element"></a>
<h2 id="root-element">Root Element</h2>
<p>The already mentioned <code>root</code> element collects the necessary pieces of data for the picture transfer. Once the file name has been set it triggers the file transfer:</p>
<pre class="qml">
<span class="type">Image</span> {
<span class="name">id</span>: <span class="name">root</span>
property <span class="type">string</span> <span class="name">remoteDevice</span>;
property <span class="type">string</span> <span class="name">fileName</span>;
<span class="name">onFileNameChanged</span>: {
<span class="name">fileTransfer</span>.<span class="name">initTransfer</span>(<span class="name">remoteDevice</span>, <span class="name">fileName</span>);
<span class="name">loader</span>.<span class="name">source</span> <span class="operator">=</span> <span class="string">"FileSending.qml"</span>
}
<span class="name">onFileNameChanged</span>: {
<span class="name">fileTransfer</span>.<span class="name">initTransfer</span>(<span class="name">remoteDevice</span>, <span class="name">fileName</span>);
<span class="name">loader</span>.<span class="name">source</span> <span class="operator">=</span> <span class="string">"FileSending.qml"</span>
}
</pre>
<a name="file-transfer"></a>
<h2 id="file-transfer">File Transfer</h2>
<p>The file transfer is implemented in C++:</p>
<pre class="cpp">
<span class="type">void</span> FileTransfer<span class="operator">::</span>initTransfer(<span class="type">QString</span> address<span class="operator">,</span> <span class="type">QString</span> fileName)
{
<a href="../qtcore/qtglobal.html#qDebug">qDebug</a>() <span class="operator"><</span><span class="operator"><</span> <span class="string">"Begin sharing file: "</span> <span class="operator"><</span><span class="operator"><</span> address <span class="operator"><</span><span class="operator"><</span> fileName;
<span class="type">QBluetoothAddress</span> btAddress <span class="operator">=</span> <span class="type">QBluetoothAddress</span>(address);
<span class="type">QBluetoothTransferRequest</span> request(btAddress);
<span class="type">QFile</span> <span class="operator">*</span>file <span class="operator">=</span> <span class="keyword">new</span> <span class="type">QFile</span>(fileName);
reply <span class="operator">=</span> manager<span class="operator">.</span>put(request<span class="operator">,</span> file);
connect(reply<span class="operator">,</span> SIGNAL(transferProgress(<span class="type">qint64</span><span class="operator">,</span><span class="type">qint64</span>))<span class="operator">,</span> <span class="keyword">this</span><span class="operator">,</span> SLOT(updateProgress(<span class="type">qint64</span><span class="operator">,</span><span class="type">qint64</span>)));
}
</pre>
<p>and exposed to QML via a context property:</p>
<pre class="cpp">
<span class="type">QQuickView</span> view;
FileTransfer fileTransfer;
view<span class="operator">.</span>rootContext()<span class="operator">-</span><span class="operator">></span>setContextProperty(<span class="string">"fileTransfer"</span><span class="operator">,</span> <span class="type">QVariant</span><span class="operator">::</span>fromValue(<span class="operator">&</span>fileTransfer));
</pre>
<p>Files:</p>
<ul>
<li><a href="qtbluetooth-picturetransfer-button-qml.html">picturetransfer/Button.qml</a></li>
<li><a href="qtbluetooth-picturetransfer-devicediscovery-qml.html">picturetransfer/DeviceDiscovery.qml</a></li>
<li><a href="qtbluetooth-picturetransfer-filesending-qml.html">picturetransfer/FileSending.qml</a></li>
<li><a href="qtbluetooth-picturetransfer-pictureselector-qml.html">picturetransfer/PictureSelector.qml</a></li>
<li><a href="qtbluetooth-picturetransfer-bttransfer-qml.html">picturetransfer/bttransfer.qml</a></li>
<li><a href="qtbluetooth-picturetransfer-filetransfer-cpp.html">picturetransfer/filetransfer.cpp</a></li>
<li><a href="qtbluetooth-picturetransfer-filetransfer-h.html">picturetransfer/filetransfer.h</a></li>
<li><a href="qtbluetooth-picturetransfer-main-cpp.html">picturetransfer/main.cpp</a></li>
<li><a href="qtbluetooth-picturetransfer-picturetransfer-pro.html">picturetransfer/picturetransfer.pro</a></li>
<li><a href="qtbluetooth-picturetransfer-qmltransfer-qrc.html">picturetransfer/qmltransfer.qrc</a></li>
</ul>
</div>
<p><b>See also </b><a href="qtbluetooth-index.html">Qt Bluetooth</a>.</p>
<!-- @@@picturetransfer -->
</div>
</div>
</div>
</div>
</div>
<div class="footer">
<p>
<acronym title="Copyright">©</acronym> 2016 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>
|