[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">&gt; Hi,<br>&gt;  <br>&gt; I&#39;ve changed your code:<br>&gt;  \
<br>&gt;        def dropEvent(self, event: QDropEvent):<br>&gt;                 data \
= event.mimeData()<br>&gt;                 print(&quot;data.text():&quot;, \
data.text(), type(data.text()))<br>&gt;                 \
print(&quot;data.data(&#39;text/plain&#39;):&quot;, \
str(data.data(&#39;text/plain&#39;)),<br>&gt;                               \
type(data.data(&#39;text/plain&#39;)))<br>&gt;  <br>&gt;  And the result:<br>&gt;  \
<br>&gt;  data.text(): Déjà -vu &lt;class &#39;str&#39;&gt;<br>&gt;  \
data.data(&#39;text/plain&#39;): b&#39;D\xc3\xa9j\xc3\xa0-vu&#39; &lt;class<br>&gt;  \
&#39;PyQt5.QtCore.QByteArray&#39;&gt;<br>&gt;  <br>&gt;  On Ubuntu Mate, the text \
&quot;Déjà -vu&quot; is dragged from Pluma (old Gedit)<br>&gt;  <br>&gt;  \
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 &#39;text/plain&#39; \
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