[QGIS-Developer] Accessing clipboard from PyQGis

Martin Pergler mp at pergler.org
Wed May 22 01:36:28 PDT 2019


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20190522/01cc8ec4/attachment.html>


More information about the QGIS-Developer mailing list