<div dir="ltr">You could use QTextEdit.setHtml by updating each time the html contents, or, eventually, use a QTextDocument for the QTextEdit and then edit QTextDocument by inserting QTextDocumentFragments.</div><br><div class="gmail_quote"><div dir="ltr">Il giorno mar 21 ago 2018 alle ore 10:51 Maziar Parsijani <<a href="mailto:maziar.parsijani@gmail.com">maziar.parsijani@gmail.com</a>> ha scritto:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="m_6660038330676751889gmail-post-text">
<p>In this code self.SearchResults = QtWidgets.QTextEdit(self) and it retrieve some text from sqlite3.db
Now I need to change font and color for: </p>
<pre class="m_6660038330676751889gmail-lang-py m_6660038330676751889gmail-prettyprint m_6660038330676751889gmail-prettyprinted"><code><span class="m_6660038330676751889gmail-pln"> self</span><span class="m_6660038330676751889gmail-pun">.</span><span class="m_6660038330676751889gmail-typ">SearchResults</span><span class="m_6660038330676751889gmail-pun">.</span><span class="m_6660038330676751889gmail-pln">append</span><span class="m_6660038330676751889gmail-pun">(</span><span class="m_6660038330676751889gmail-str">'{0} - {1}'</span><span class="m_6660038330676751889gmail-pun">.</span><span class="m_6660038330676751889gmail-pln">format</span><span class="m_6660038330676751889gmail-pun">(</span><span class="m_6660038330676751889gmail-pln">a</span><span class="m_6660038330676751889gmail-pun">,</span><span class="m_6660038330676751889gmail-pln"> str</span><span class="m_6660038330676751889gmail-pun">(</span><span class="m_6660038330676751889gmail-pln">row</span><span class="m_6660038330676751889gmail-pun">[</span><span class="m_6660038330676751889gmail-lit">0</span><span class="m_6660038330676751889gmail-pun">])))</span><span class="m_6660038330676751889gmail-pln">
self</span><span class="m_6660038330676751889gmail-pun">.</span><span class="m_6660038330676751889gmail-typ">SearchResults</span><span class="m_6660038330676751889gmail-pun">.</span><span class="m_6660038330676751889gmail-pln">append</span><span class="m_6660038330676751889gmail-pun">(</span><span class="m_6660038330676751889gmail-str">'{0} - {1}'</span><span class="m_6660038330676751889gmail-pun">.</span><span class="m_6660038330676751889gmail-pln">format</span><span class="m_6660038330676751889gmail-pun">(</span><span class="m_6660038330676751889gmail-pln">a</span><span class="m_6660038330676751889gmail-pun">,</span><span class="m_6660038330676751889gmail-pln"> str</span><span class="m_6660038330676751889gmail-pun">(</span><span class="m_6660038330676751889gmail-pln">row</span><span class="m_6660038330676751889gmail-pun">[</span><span class="m_6660038330676751889gmail-lit">1</span><span class="m_6660038330676751889gmail-pun">])))</span></code></pre>
<p>These 2lines retrieve text from database I want them to be different from each other by font and color.</p>
<pre class="m_6660038330676751889gmail-lang-py m_6660038330676751889gmail-prettyprint m_6660038330676751889gmail-prettyprinted"><code><span class="m_6660038330676751889gmail-pln"> </span><span class="m_6660038330676751889gmail-kwd">def</span><span class="m_6660038330676751889gmail-pln"> </span><span class="m_6660038330676751889gmail-typ">SearchIn</span><span class="m_6660038330676751889gmail-pun">(</span><span class="m_6660038330676751889gmail-pln">self</span><span class="m_6660038330676751889gmail-pun">):</span><span class="m_6660038330676751889gmail-pln">
cur </span><span class="m_6660038330676751889gmail-pun">=</span><span class="m_6660038330676751889gmail-pln"> conn</span><span class="m_6660038330676751889gmail-pun">.</span><span class="m_6660038330676751889gmail-pln">cursor</span><span class="m_6660038330676751889gmail-pun">()</span><span class="m_6660038330676751889gmail-pln">
conn</span><span class="m_6660038330676751889gmail-pun">.</span><span class="m_6660038330676751889gmail-pln">text_factory </span><span class="m_6660038330676751889gmail-pun">=</span><span class="m_6660038330676751889gmail-pln"> str
cur</span><span class="m_6660038330676751889gmail-pun">.</span><span class="m_6660038330676751889gmail-pln">execute</span><span class="m_6660038330676751889gmail-pun">(</span><span class="m_6660038330676751889gmail-str">" SELECT text,text1 FROM Translation WHERE priority = ?"</span><span class="m_6660038330676751889gmail-pun">,</span><span class="m_6660038330676751889gmail-pln"> </span><span class="m_6660038330676751889gmail-pun">(</span><span class="m_6660038330676751889gmail-pln">self</span><span class="m_6660038330676751889gmail-pun">.</span><span class="m_6660038330676751889gmail-pln">SINDEX</span><span class="m_6660038330676751889gmail-pun">,))</span><span class="m_6660038330676751889gmail-pln">
self</span><span class="m_6660038330676751889gmail-pun">.</span><span class="m_6660038330676751889gmail-typ">SearchResults</span><span class="m_6660038330676751889gmail-pun">.</span><span class="m_6660038330676751889gmail-pln">clear</span><span class="m_6660038330676751889gmail-pun">()</span><span class="m_6660038330676751889gmail-pln">
a </span><span class="m_6660038330676751889gmail-pun">=</span><span class="m_6660038330676751889gmail-pln"> </span><span class="m_6660038330676751889gmail-lit">1</span><span class="m_6660038330676751889gmail-pln">
</span><span class="m_6660038330676751889gmail-kwd">for</span><span class="m_6660038330676751889gmail-pln"> row </span><span class="m_6660038330676751889gmail-kwd">in</span><span class="m_6660038330676751889gmail-pln"> cur</span><span class="m_6660038330676751889gmail-pun">:</span><span class="m_6660038330676751889gmail-pln">
self</span><span class="m_6660038330676751889gmail-pun">.</span><span class="m_6660038330676751889gmail-typ">SearchResults</span><span class="m_6660038330676751889gmail-pun">.</span><span class="m_6660038330676751889gmail-pln">append</span><span class="m_6660038330676751889gmail-pun">(</span><span class="m_6660038330676751889gmail-str">'{0} - {1}'</span><span class="m_6660038330676751889gmail-pun">.</span><span class="m_6660038330676751889gmail-pln">format</span><span class="m_6660038330676751889gmail-pun">(</span><span class="m_6660038330676751889gmail-pln">a</span><span class="m_6660038330676751889gmail-pun">,</span><span class="m_6660038330676751889gmail-pln"> str</span><span class="m_6660038330676751889gmail-pun">(</span><span class="m_6660038330676751889gmail-pln">row</span><span class="m_6660038330676751889gmail-pun">[</span><span class="m_6660038330676751889gmail-lit">0</span><span class="m_6660038330676751889gmail-pun">])))</span><span class="m_6660038330676751889gmail-pln">
self</span><span class="m_6660038330676751889gmail-pun">.</span><span class="m_6660038330676751889gmail-typ">SearchResults</span><span class="m_6660038330676751889gmail-pun">.</span><span class="m_6660038330676751889gmail-pln">append</span><span class="m_6660038330676751889gmail-pun">(</span><span class="m_6660038330676751889gmail-str">'{0} - {1}'</span><span class="m_6660038330676751889gmail-pun">.</span><span class="m_6660038330676751889gmail-pln">format</span><span class="m_6660038330676751889gmail-pun">(</span><span class="m_6660038330676751889gmail-pln">a</span><span class="m_6660038330676751889gmail-pun">,</span><span class="m_6660038330676751889gmail-pln"> str</span><span class="m_6660038330676751889gmail-pun">(</span><span class="m_6660038330676751889gmail-pln">row</span><span class="m_6660038330676751889gmail-pun">[</span><span class="m_6660038330676751889gmail-lit">1</span><span class="m_6660038330676751889gmail-pun">])))</span><span class="m_6660038330676751889gmail-pln">
a </span><span class="m_6660038330676751889gmail-pun">=</span><span class="m_6660038330676751889gmail-pln"> a </span><span class="m_6660038330676751889gmail-pun">+</span><span class="m_6660038330676751889gmail-pln"> </span><span class="m_6660038330676751889gmail-lit">1</span></code></pre>
</div></div>
_______________________________________________<br>
PyQt mailing list <a href="mailto:PyQt@riverbankcomputing.com" target="_blank">PyQt@riverbankcomputing.com</a><br>
<a href="https://www.riverbankcomputing.com/mailman/listinfo/pyqt" rel="noreferrer" target="_blank">https://www.riverbankcomputing.com/mailman/listinfo/pyqt</a></blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">È difficile avere una convinzione precisa quando si parla delle ragioni del cuore. - "Sostiene Pereira", Antonio Tabucchi<br><a href="http://www.jidesk.net">http://www.jidesk.net</a></div>