[SailfishDevel] System clipboard and QApplication
Andrey Kozhevnikov
coderusinbox at gmail.com
Thu Apr 24 06:16:46 UTC 2014
use QGuiApplication or QCoreApplication. QApplication itself is deprecated.
There is also dark side hack for using QML clipboard:
TextEdit {
id: clipboard
visible: false
function setClipboard(value) {
text = value
selectAll()
copy()
}
function getClipboard() {
text = ""
paste()
return text
}
}
24.04.2014 12:03, Samuli Silvius ?????:
> Hi,
>
> I use system clipboard in QML app with small C++ adapter
>
> #ifndef QMLCLIPBOARDADAPTER_H
> #define QMLCLIPBOARDADAPTER_H
> #include <QApplication>
> #include <QClipboard>
> #include <QObject>
> class QmlClipboardAdapter : public QObject
> {
> Q_OBJECT
> public:
> explicit QmlClipboardAdapter(QObject *parent = 0) : QObject(parent) {
> clipboard = QApplication::clipboard();
> }
> Q_INVOKABLE void setText(QString text){
> clipboard->setText(text, QClipboard::Clipboard);
> clipboard->setText(text, QClipboard::Selection);
> }
> private:
> QClipboard *clipboard;
> };
> #endif // QMLCLIPBOARDADAPTER_H
>
> And it's working fine. But this requires that I have to add
>
> QT += widgets
>
> 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.
>
> ERROR [/usr/share/harbour-jolla2gether/qml/harbour-jolla2gether.qml]
> Import 'QmlClipboardAdapter 1.0' is not allowed
> ERROR [/usr/bin/harbour-jolla2gether] Cannot link to shared library:
> libQt5Widgets.so.5
>
>
> Is there are way around this?
>
> Br
> -Samuli
>
>
> _______________________________________________
> SailfishOS.org Devel mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.sailfishos.org/pipermail/devel/attachments/20140424/f70c864c/attachment.html>
More information about the Devel
mailing list