[prev in list] [next in list] [prev in thread] [next in thread]
List: pykde
Subject: Re: Issues with QMimeData.text()
From: Bryce Beagle <bryce.beagle () gmail ! com>
Date: 2020-06-13 20:43:48
Message-ID: CAKKt4mZRpENMc0TjafeNdiL=AhGzHXaLG0zyNqLduddu9j+LWA () mail ! gmail ! com
[Download RAW message or body]
> 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
[Attachment #3 (text/html)]
<div dir="ltr">> Hi,<br>> <br>> I've changed your code:<br>> \
<br>> def dropEvent(self, event: QDropEvent):<br>> data \
= event.mimeData()<br>> print("data.text():", \
data.text(), type(data.text()))<br>> \
print("data.data('text/plain'):", \
str(data.data('text/plain')),<br>> \
type(data.data('text/plain')))<br>> <br>> And the result:<br>> \
<br>> data.text(): Déjà -vu <class 'str'><br>> \
data.data('text/plain'): b'D\xc3\xa9j\xc3\xa0-vu' <class<br>> \
'PyQt5.QtCore.QByteArray'><br>> <br>> On Ubuntu Mate, the text \
"Déjà -vu" is dragged from Pluma (old Gedit)<br>> <br>> \
Vincent<br><div><br></div><div>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.</div><div><br></div><div>Another side note, it seems strange to me that \
QMimeData.data() returns a QByteArray instead of a python bytes/bytearray object. \
</div><div><br></div><div>Thanks,</div><div>Bryce</div></div>
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic