<?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[I need a function to add some HTML attribute to a QTextObject?]]></title><description><![CDATA[<p dir="auto">Are there any function act like this in <strong>Qt version <em>6.4.1</em></strong>:</p>
<pre><code class="language-c++">// a QTextObject inherited class
QTextCursor cursor = textCursor();
QtextBlock* blk = cursor.block();
QTextBlockFormat fmt = blk-&gt;format();
// method I wonder
fmt.setHtmlAttribute(QTextBlockFormat::HtmlAttr::Style, 
    "font-weight: 700");
qDebug() &lt;&lt; toHtml();
</code></pre>
<p dir="auto">Will output</p>
<pre><code class="language-html">...
&lt;p style="font-weight: 700"&gt;current block&lt;/p&gt;
...
</code></pre>
<p dir="auto">Without modifying the HTML through <code>setHtml(...) </code> or <code>setFontWeight(int) </code>.</p>
<p dir="auto">Is there any way to do that in Qt 6? Thanks!</p>
]]></description><link>https://forum.qt.io/topic/141308/i-need-a-function-to-add-some-html-attribute-to-a-qtextobject</link><generator>RSS for Node</generator><lastBuildDate>Mon, 27 Apr 2026 22:08:48 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/141308.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 07 Dec 2022 11:54:13 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to I need a function to add some HTML attribute to a QTextObject? on Wed, 07 Dec 2022 12:08:10 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jackmyson">@<bdi>JackMyson</bdi></a><br />
Qt's rich text handling does not accept arbitrary HTML, only a subset.  So I don't think it caters for you just inserting some HTML attribute.  I would expect to accomplish your request via <code>setHtml(...)</code> or <code>setFontWeight(int)</code>?</p>
]]></description><link>https://forum.qt.io/post/739322</link><guid isPermaLink="true">https://forum.qt.io/post/739322</guid><dc:creator><![CDATA[JonB]]></dc:creator><pubDate>Wed, 07 Dec 2022 12:08:10 GMT</pubDate></item></channel></rss>