<div dir="ltr">Hi,<div><br></div><div>I use system clipboard in QML app with small C++ adapter</div><div><br></div><div><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,128)">#ifndef</span><span style="color:rgb(192,192,192)"> </span>QMLCLIPBOARDADAPTER_H</pre>

<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,128)">#define</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">QMLCLIPBOARDADAPTER_H</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,128)">#include</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)"><QApplication></span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,128)">#include</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)"><QClipboard></span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,128)">#include</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)"><QObject></span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(128,128,0)">class</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">QmlClipboardAdapter</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">:</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">public</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">QObject</span></pre>

<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,0)">{</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">    </span><span style="color:rgb(0,0,128)">Q_OBJECT</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(128,128,0)">public</span><span style="color:rgb(0,0,0)">:</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">    </span><span style="color:rgb(128,128,0)">explicit</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">QmlClipboardAdapter</span><span style="color:rgb(0,0,0)">(</span><span style="color:rgb(128,0,128)">QObject</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">*</span><span style="color:rgb(0,0,0)">parent</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">=</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,128)">0</span><span style="color:rgb(0,0,0)">)</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">:</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">QObject</span><span style="color:rgb(0,0,0)">(</span><span style="color:rgb(0,0,0)">parent</span><span style="color:rgb(0,0,0)">)</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">{</span></pre>

<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">        </span><span style="color:rgb(128,0,0)">clipboard</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">=</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">QApplication</span><span style="color:rgb(0,0,0)">::</span><span style="color:rgb(0,0,0)">clipboard</span><span style="color:rgb(0,0,0)">();</span></pre>

<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">    </span><span style="color:rgb(0,0,0)">}</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">    </span><span style="color:rgb(128,0,128)">Q_INVOKABLE</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,128,0)">void</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">setText</span><span style="color:rgb(0,0,0)">(</span><span style="color:rgb(128,0,128)">QString</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">text</span><span style="color:rgb(0,0,0)">){</span></pre>

<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">        </span><span style="color:rgb(128,0,0)">clipboard</span><span style="color:rgb(0,0,0)">-></span><span style="color:rgb(0,0,0)">setText</span><span style="color:rgb(0,0,0)">(</span><span style="color:rgb(0,0,0)">text</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">QClipboard</span><span style="color:rgb(0,0,0)">::</span><span style="color:rgb(128,0,128)">Clipboard</span><span style="color:rgb(0,0,0)">);</span></pre>

<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">        </span><span style="color:rgb(128,0,0)">clipboard</span><span style="color:rgb(0,0,0)">-></span><span style="color:rgb(0,0,0)">setText</span><span style="color:rgb(0,0,0)">(</span><span style="color:rgb(0,0,0)">text</span><span style="color:rgb(0,0,0)">,</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(128,0,128)">QClipboard</span><span style="color:rgb(0,0,0)">::</span><span style="color:rgb(128,0,128)">Selection</span><span style="color:rgb(0,0,0)">);</span></pre>

<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">    </span><span style="color:rgb(0,0,0)">}</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(128,128,0)">private</span><span style="color:rgb(0,0,0)">:</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(192,192,192)">    </span><span style="color:rgb(128,0,128)">QClipboard</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,0,0)">*</span><span style="color:rgb(128,0,0)">clipboard</span><span style="color:rgb(0,0,0)">;</span></pre>

<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,0)">};</span></pre>
<pre style="margin-top:0px;margin-bottom:0px"><br></pre>
<pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(0,0,128)">#endif</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">//</span><span style="color:rgb(192,192,192)"> </span><span style="color:rgb(0,128,0)">QMLCLIPBOARDADAPTER_H</span></pre>

<pre style="margin-top:0px;margin-bottom:0px"><br></pre></div><div><br></div><div>And it's working fine. But this requires that I have to add </div><div><br></div><div><pre style="margin-top:0px;margin-bottom:0px"><span style="color:rgb(128,0,128)">QT</span><span style="color:rgb(192,192,192)"> </span>+=<span style="color:rgb(192,192,192)"> </span>widgets</pre>
</div><div><br></div><div>to .pro file and seems it's not supported by Jolla Harbour as also Jolla SDK RPM validation gives me an errors. I have updated the SDK to the latest.</div><div><br></div><div><font face="courier new, monospace" size="1">ERROR [/usr/share/harbour-jolla2gether/qml/harbour-jolla2gether.qml] Import 'QmlClipboardAdapter 1.0' is not allowed<br>
</font></div><div><font face="courier new, monospace" size="1">ERROR [/usr/bin/harbour-jolla2gether] Cannot link to shared library: libQt5Widgets.so.5</font><br></div><div><br></div><div><br></div><div>Is there are way around this?</div>
<div><br></div><div>Br</div><div>-Samuli</div></div>