<?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[Cant insert anchor in QTextEdit. Five years-old bug?]]></title><description><![CDATA[<p dir="auto">I have object textArea by QTextEdit class. I mouse select word, and click special button. Button action - is append anchor to text (link href in QString refereceUrl):</p>
<pre><code>  // Set link
  QTextCharFormat charFormat;
  charFormat.setAnchorHref(refereceUrl);

  // If link not empty
  if(refereceUrl.length()&gt;0)
  {
    charFormat.setAnchor(true);
    textArea-&gt;textCursor().mergeCharFormat(charFormat);
  }
  else
  {
    // Else link is empty, and we do remove anchor
    charFormat.setAnchor(false);
    textArea-&gt;textCursor().setCharFormat(charFormat);
  }
</code></pre>
<p dir="auto">The anchor for selected text is setted, but text dont underline and blue. Text visible as normal text.</p>
<p dir="auto">In HTML source i see:</p>
<p dir="auto">Before set anchor:</p>
<pre><code>&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"&gt;This any text.&lt;/p&gt;
</code></pre>
<p dir="auto">After set anchor to word "any":</p>
<pre><code>&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"&gt;This &lt;a href="https://link.com"&gt;any&lt;/a&gt; text.&lt;/p&gt;
</code></pre>
<p dir="auto">... and word "any" view as normal word without underline and blue color.</p>
<p dir="auto">But! If get all HTML code from <strong>textArea.html</strong>, and set it again by <strong>textArea.setHtml()</strong>, then whord "any" view as underline and blue color. The HTML-code Qt automatic set to:</p>
<pre><code>&lt;p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"&gt;This &lt;a href="https://link.ru"&gt;&lt;span style=" text-decoration: underline; color:#0000ff;"&gt;any&lt;/span&gt;&lt;/a&gt; text.&lt;/p&gt;
</code></pre>
<p dir="auto">I have this problem now (Qt 5.4.2), and find this problem in Russian forum at 2010 year:</p>
<p dir="auto"><a href="http://www.forum.crossplatform.ru/index.php?showtopic=4670&amp;mode=linearplus" target="_blank" rel="noopener noreferrer nofollow ugc">http://www.forum.crossplatform.ru/index.php?showtopic=4670&amp;mode=linearplus</a></p>
<p dir="auto">Q: This is bug? If this is not bug, please write, how to set anchor in QTextEdit as underline and blue color.</p>
]]></description><link>https://forum.qt.io/topic/62366/cant-insert-anchor-in-qtextedit-five-years-old-bug</link><generator>RSS for Node</generator><lastBuildDate>Sat, 10 Oct 2026 02:26:51 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/62366.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 05 Jan 2016 19:08:20 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Cant insert anchor in QTextEdit. Five years-old bug? on Thu, 22 Aug 2019 02:19:10 GMT]]></title><description><![CDATA[<p dir="auto">To remove link...</p>
<pre><code>qTextCharFormat = self.__qTextEdit.textCursor().charFormat()
if qTextCharFormat.isAnchor():
   qTextCharFormat.setAnchor(False)
   qTextCharFormat.setFontUnderline(False)
   qTextCharFormat.clearForeground()
   self.__qTextEdit.textCursor().setCharFormat(qTextCharFormat)
</code></pre>
<p dir="auto">...haven't looked at adding link yet but assuming something inverse of the above.</p>
<p dir="auto">Cheers</p>
]]></description><link>https://forum.qt.io/post/547271</link><guid isPermaLink="true">https://forum.qt.io/post/547271</guid><dc:creator><![CDATA[MartinSwede]]></dc:creator><pubDate>Thu, 22 Aug 2019 02:19:10 GMT</pubDate></item><item><title><![CDATA[Reply to Cant insert anchor in QTextEdit. Five years-old bug? on Wed, 06 Jan 2016 21:59:41 GMT]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">Sounds like a bug indeed. It looks like there's a rendering (or rather a re-rendering) issue. You should check the <a href="http://bugreports.qt.io" target="_blank" rel="noopener noreferrer nofollow ugc">bug report system</a> to see if it's something known. If not please consider opening a new report providing a minimal compilable example reproducing this behavior.</p>
]]></description><link>https://forum.qt.io/post/305911</link><guid isPermaLink="true">https://forum.qt.io/post/305911</guid><dc:creator><![CDATA[SGaist]]></dc:creator><pubDate>Wed, 06 Jan 2016 21:59:41 GMT</pubDate></item></channel></rss>