Issues with QMimeData.text()

Bryce Beagle bryce.beagle at gmail.com
Sat Jun 13 21:43:48 BST 2020


> Hi,
>
> I've changed your code:
>
>     def dropEvent(self, event: QDropEvent):
>         data = event.mimeData()
>         print("data.text():", data.text(), type(data.text()))
>         print("data.data('text/plain'):", str(data.data('text/plain')),
>                type(data.data('text/plain')))
>
> And the result:
>
> data.text(): Déjà-vu <class 'str'>
> data.data('text/plain'): b'D\xc3\xa9j\xc3\xa0-vu' <class
> 'PyQt5.QtCore.QByteArray'>
>
> On Ubuntu Mate, the text "Déjà-vu" is dragged from Pluma (old Gedit)
>
> Vincent

I apologize for being as clear as I would have liked to be in my original
email, but the issue I presented only occurs from some sources. I can
drag-and-drop perfectly fine from Gedit. Other sources, such as Chromium,
Slack, and PyCharm do not work (i.e. QMimeData.text() only returns an empty
string), even though they provide a 'text/plain' format.

Another side note, it seems strange to me that QMimeData.data() returns a
QByteArray instead of a python bytes/bytearray object.

Thanks,
Bryce
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20200613/a764e050/attachment.htm>


More information about the PyQt mailing list