[QGIS-Developer] Accessing clipboard from PyQGis
C Hamilton
adenaculture at gmail.com
Wed May 22 06:10:26 PDT 2019
I don't know if this helps but I copy data from QGIS onto the clipboard in
this manner. I'm sure you can go the other way as well.
from qgis.PyQt.QtWidgets import QApplication
text = 'This is a test'
clipboard = QApplication.clipboard()
clipboard.setText(text)
Calvin
On Wed, May 22, 2019 at 4:36 AM Martin Pergler <mp at pergler.org> wrote:
> Can one access the internal QGIS clipboard (as defined in
> qgsclipboard.h/cpp) in a python script or plugin within QGis desktop?
>
> I've tried QgsApplication.clipboard() and QApplication.clipboard, both of
> which return a PyQt5 QClipboard object rather than a QgsClipboard.
>
> In a plugin I'm developing, I'd love to make use of features copied to the
> clipboard in native format (e.g. via the copyOf() method of QgsClipboard).
> However, if I get a QClipboard I only have access to a text()
> representation, the WKT or geoJson format of the features depending
> on Settings -> Options -> Data sources -> Copy features as... The same
> is also accessible as -- apparently -- the only MIME type via
> .mimeData().formats().
>
> I'm running QGis version 3.6.3 on Win10. (Note this is dup of
> https://gis.stackexchange.com/questions/322878/accessing-internal-qgis-clipboard-in-python that
> I asked a week ago).
>
> Thanks!
>
> --
> Martin Pergler
> mp at pergler.org
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20190522/41846366/attachment.html>
More information about the QGIS-Developer
mailing list