<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[QClipboard and QMimeData not working for urls]]></title><description><![CDATA[<pre><code>    QUrl url = QUrl("http://www.google.com");
    QMimeData *mime = new QMimeData;
    mime-&gt;setUrls({ url });

    QGuiApplication::clipboard()-&gt;setMimeData(mime);
</code></pre>
<p dir="auto">It's not working, the url is not being copied to Clipboard. The clipboard works if I use something like <code>setText</code> but not this way.</p>
]]></description><link>https://forum.qt.io/topic/91290/qclipboard-and-qmimedata-not-working-for-urls</link><generator>RSS for Node</generator><lastBuildDate>Fri, 16 Oct 2026 21:52:33 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/91290.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 03 Jun 2018 01:24:11 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to QClipboard and QMimeData not working for urls on Sun, 03 Jun 2018 09:06:04 GMT]]></title><description><![CDATA[<p dir="auto">Thank you <a class="plugin-mentions-user plugin-mentions-a" href="/user/mrjj">@<bdi>mrjj</bdi></a></p>
]]></description><link>https://forum.qt.io/post/461631</link><guid isPermaLink="true">https://forum.qt.io/post/461631</guid><dc:creator><![CDATA[Mr Gisa]]></dc:creator><pubDate>Sun, 03 Jun 2018 09:06:04 GMT</pubDate></item><item><title><![CDATA[Reply to QClipboard and QMimeData not working for urls on Sun, 03 Jun 2018 09:06:06 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mr-gisa">@<bdi>Mr-Gisa</bdi></a><br />
No, not really as url works as text too.<br />
In theory, the URL could contain special characters and languages but<br />
the text format should also handle that nowadays.</p>
<p dir="auto">Also text format is often best for pasting to externals app.<br />
Some do check mimetypes and can paste many formats but many app<br />
like TEXT and IMAGE and ignores the rest. ( a bit oversimplified)</p>
<p dir="auto">So i think in your use case, text format will work fine.</p>
]]></description><link>https://forum.qt.io/post/461630</link><guid isPermaLink="true">https://forum.qt.io/post/461630</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Sun, 03 Jun 2018 09:06:06 GMT</pubDate></item><item><title><![CDATA[Reply to QClipboard and QMimeData not working for urls on Sun, 03 Jun 2018 08:56:48 GMT]]></title><description><![CDATA[<p dir="auto">Is there a problem changing from using mime data and using just <code>setText</code> for urls or it's going to be a problem?</p>
]]></description><link>https://forum.qt.io/post/461629</link><guid isPermaLink="true">https://forum.qt.io/post/461629</guid><dc:creator><![CDATA[Mr Gisa]]></dc:creator><pubDate>Sun, 03 Jun 2018 08:56:48 GMT</pubDate></item><item><title><![CDATA[Reply to QClipboard and QMimeData not working for urls on Sun, 03 Jun 2018 08:50:24 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mr-gisa">@<bdi>Mr-Gisa</bdi></a><br />
Hi<br />
Just as a note:<br />
On windows, most apps checks the format put in clipboard with the data.<br />
So notepad for instance, wont paste types besides TEXT etc.<br />
you could try with<br />
<a href="https://www.nirsoft.net/utils/inside_clipboard.html" target="_blank" rel="noopener noreferrer nofollow ugc">https://www.nirsoft.net/utils/inside_clipboard.html</a><br />
and see what it shows.</p>
]]></description><link>https://forum.qt.io/post/461628</link><guid isPermaLink="true">https://forum.qt.io/post/461628</guid><dc:creator><![CDATA[mrjj]]></dc:creator><pubDate>Sun, 03 Jun 2018 08:50:24 GMT</pubDate></item><item><title><![CDATA[Reply to QClipboard and QMimeData not working for urls on Sun, 03 Jun 2018 08:08:13 GMT]]></title><description><![CDATA[<p dir="auto">For me I didn't work even on the browser (Firefox), I did the same <code>qDebug</code> thing you did and it's returning the urls, but not copying to the clipboard actually. That is so weird.</p>
<hr />
<p dir="auto">I noticed that I can only paste on <code>QLineEdit</code> inside my application, I can't paste in other applications.</p>
]]></description><link>https://forum.qt.io/post/461625</link><guid isPermaLink="true">https://forum.qt.io/post/461625</guid><dc:creator><![CDATA[Mr Gisa]]></dc:creator><pubDate>Sun, 03 Jun 2018 08:08:13 GMT</pubDate></item><item><title><![CDATA[Reply to QClipboard and QMimeData not working for urls on Sun, 03 Jun 2018 07:44:23 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mr-gisa">@<bdi>Mr-Gisa</bdi></a><br />
Nope, could not paste it into a text editor but I could paste into the url text box on the google chrome browser and the Safari browser...<br />
Maybe that is because it is a url mime type and not a text type? However, I must admit I am not an expert on mime type behaviour :-)</p>
]]></description><link>https://forum.qt.io/post/461623</link><guid isPermaLink="true">https://forum.qt.io/post/461623</guid><dc:creator><![CDATA[kenchan]]></dc:creator><pubDate>Sun, 03 Jun 2018 07:44:23 GMT</pubDate></item><item><title><![CDATA[Reply to QClipboard and QMimeData not working for urls on Sun, 03 Jun 2018 07:32:33 GMT]]></title><description><![CDATA[<p dir="auto">Have you tried copying to Clipboard and using ctrl+v on something like notepad? For me doesn't work, idk why.</p>
]]></description><link>https://forum.qt.io/post/461622</link><guid isPermaLink="true">https://forum.qt.io/post/461622</guid><dc:creator><![CDATA[Mr Gisa]]></dc:creator><pubDate>Sun, 03 Jun 2018 07:32:33 GMT</pubDate></item><item><title><![CDATA[Reply to QClipboard and QMimeData not working for urls on Sun, 03 Jun 2018 07:30:56 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mr-gisa">@<bdi>Mr-Gisa</bdi></a></p>
<p dir="auto">Well that is strange, because when I do something like this in my application I can get the urls back from the clipboard.<br />
So I guess it does work and you are doing something wrong...</p>
<pre><code>    QUrl url1 = QUrl("http://www.google.com");
    QUrl url2 = QUrl("http://www.microsoft.com");
    QMimeData *mime = new QMimeData;
    mime-&gt;setUrls({ url1, url2 });
    qDebug() &lt;&lt; "urls : " &lt;&lt; mime-&gt;urls();

    QClipboard *clipboard = QApplication::clipboard();
    if(clipboard)
    {
        clipboard-&gt;setMimeData(mime);
       const QMimeData *clipMime = clipboard-&gt;mimeData();
       qDebug() &lt;&lt; "mime urls : " &lt;&lt; clipMime-&gt;urls();
    }
</code></pre>
]]></description><link>https://forum.qt.io/post/461621</link><guid isPermaLink="true">https://forum.qt.io/post/461621</guid><dc:creator><![CDATA[kenchan]]></dc:creator><pubDate>Sun, 03 Jun 2018 07:30:56 GMT</pubDate></item><item><title><![CDATA[Reply to QClipboard and QMimeData not working for urls on Sun, 03 Jun 2018 07:04:28 GMT]]></title><description><![CDATA[<p dir="auto">Yes, but it's not working, the urls are not being copied to the Clipboard. It only works if I use <code>setText</code> and <code>QUrl::toString</code>, using mime and <code>setMime</code> isn't working.</p>
]]></description><link>https://forum.qt.io/post/461618</link><guid isPermaLink="true">https://forum.qt.io/post/461618</guid><dc:creator><![CDATA[Mr Gisa]]></dc:creator><pubDate>Sun, 03 Jun 2018 07:04:28 GMT</pubDate></item><item><title><![CDATA[Reply to QClipboard and QMimeData not working for urls on Sun, 03 Jun 2018 06:57:11 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/mr-gisa">@<bdi>Mr-Gisa</bdi></a><br />
I guess that is how it is supposed to work..<br />
Like it says in the QClipboard docs...</p>
<pre><code>  void DropArea::paste()
  {
      const QClipboard *clipboard = QApplication::clipboard();
      const QMimeData *mimeData = clipboard-&gt;mimeData();

      if (mimeData-&gt;hasImage()) {
          setPixmap(qvariant_cast&lt;QPixmap&gt;(mimeData-&gt;imageData()));
      } else if (mimeData-&gt;hasHtml()) {
          setText(mimeData-&gt;html());
          setTextFormat(Qt::RichText);
      } else if (mimeData-&gt;hasText()) {
          setText(mimeData-&gt;text());
          setTextFormat(Qt::PlainText);
      } else {
          setText(tr("Cannot display data"));
      }
</code></pre>
]]></description><link>https://forum.qt.io/post/461615</link><guid isPermaLink="true">https://forum.qt.io/post/461615</guid><dc:creator><![CDATA[kenchan]]></dc:creator><pubDate>Sun, 03 Jun 2018 06:57:11 GMT</pubDate></item></channel></rss>