Re: [SailfishDevel] System clipboard and QApplication
Hi, See https://sailfishos.org/sailfish-silica/qml-sailfishsilica-clipboard.html -- J-P Nurmi On 25 Apr 2014, at 19:57, Samuli Silvius wrote: > Thanks a lot, the QML trick works great! > > -Samuli > > > 2014-04-24 9:16 GMT+03:00 Andrey Kozhevnikov : > 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 >> #include >> #include >> 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 > > ___ > SailfishOS.org Devel mailing list ___ SailfishOS.org Devel mailing list
Re: [SailfishDevel] System clipboard and QApplication
Thanks a lot, the QML trick works great! -Samuli 2014-04-24 9:16 GMT+03:00 Andrey Kozhevnikov : > 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 > > #include > > #include > > 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 > ___ SailfishOS.org Devel mailing list
Re: [SailfishDevel] System clipboard and QApplication
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 #include #include 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