[SailfishDevel] System clipboard and QApplication
Samuli Silvius
samuli.silvius at gmail.com
Fri Apr 25 17:57:59 UTC 2014
Thanks a lot, the QML trick works great!
-Samuli
2014-04-24 9:16 GMT+03:00 Andrey Kozhevnikov <coderusinbox at gmail.com>:
> 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
>
>
>
> _______________________________________________
> SailfishOS.org Devel mailing list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.sailfishos.org/pipermail/devel/attachments/20140425/e612d587/attachment.html>
More information about the Devel
mailing list