<?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[Problem in not getting BOLD format in QTextEdit using tohtml()]]></title><description><![CDATA[<p dir="auto">Hi All,<br />
Actually , my task is to make bold on the selected text on QTextEdit ..<br />
and finally i will be storing the QtextEdit text to a file with html format.</p>
<p dir="auto">Later ..when i do open my application , i will be populating the content back from File to QtextEdit value...but the format is not bold...which it should be..<br />
my codes are:<br />
@<br />
void CTestDlg::boldButtonPressed()<br />
{<br />
QTextCharFormat fmt;</p>
<pre><code>QTextCursor cursor = ui-&gt;textEdit-&gt;textCursor();

if (!cursor.hasSelection())
    cursor.select(QTextCursor::WordUnderCursor);

if( cursor.charFormat().fontWeight() == QFont::Bold  )
    fmt.setFontWeight( QFont::Normal);
else
{
   fmt.setFontWeight( QFont::Bold);
}


cursor.mergeCharFormat( fmt );

qDebug()&lt;&lt;"cursor.selectedText()*******************"&lt;&lt;cursor.selectedText();

ui-&gt;textEdit-&gt;mergeCurrentCharFormat(fmt);
</code></pre>
<p dir="auto">}</p>
<p dir="auto">void CtestDlg::saveToFile()<br />
{</p>
<p dir="auto">QString strText = ui-&gt;textEdit-&gt;tohtml();<br />
//then storing this string value into a file..<br />
}</p>
<p dir="auto">void CTestDlg::readFromFile()<br />
{<br />
QString strText = readFile();// here i am reading exactly..what has been stored in the file<br />
ui-&gt;textedit-&gt;settext( strText );<br />
}<br />
@</p>
<p dir="auto">Please let me know..whether i am doing anything wrong on this..</p>
]]></description><link>https://forum.qt.io/topic/10502/problem-in-not-getting-bold-format-in-qtextedit-using-tohtml</link><generator>RSS for Node</generator><lastBuildDate>Sat, 25 Apr 2026 11:32:51 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/10502.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 17 Oct 2011 15:48:29 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Problem in not getting BOLD format in QTextEdit using tohtml() on Mon, 17 Oct 2011 16:56:40 GMT]]></title><description><![CDATA[<p dir="auto">Th code works for me. What's the content of the file?</p>
]]></description><link>https://forum.qt.io/post/113586</link><guid isPermaLink="true">https://forum.qt.io/post/113586</guid><dc:creator><![CDATA[goetz]]></dc:creator><pubDate>Mon, 17 Oct 2011 16:56:40 GMT</pubDate></item></channel></rss>