<div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div>Hi,<br></div>I have found that Qsyntaxhighlighter may be better for huge data.<br></div><div>This is a code which I use but I can not get it to work on qtextedit.<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><pre style="background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:"DejaVu Sans Mono";font-size:9.1pt">self.SearchResults = QtWidgets.QTextEdit(<span style="color:rgb(148,85,141)">self</span>)<span style="color:rgb(148,85,141)"><br>self</span>.SearchResults.setPlainText(<span style="color:rgb(0,128,128);font-weight:bold">"The T t myh inH WwtT"</span>)</pre></div></blockquote></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><pre style="background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:"DejaVu Sans Mono";font-size:9.1pt">brush = QtGui.QBrush(QtCore.Qt.darkBlue, QtCore.Qt.SolidPattern)<br> keyword = QtGui.QTextCharFormat()<br> keyword.setForeground(brush)<br> keyword.setFontWeight(QtGui.QFont.Bold)<br> listKeywords = <span style="color:rgb(0,128,128);font-weight:bold">"The"<br></span><span style="color:rgb(0,128,128);font-weight:bold"> </span><span style="color:rgb(148,85,141)">self</span>.highlightingRules = [highlightRule(QtCore.QRegExp(<span style="color:rgb(0,128,128);font-weight:bold">"</span><span style="color:rgb(0,0,128);font-weight:bold">\\</span><span style="color:rgb(0,128,128);font-weight:bold">b" </span>+ key + <span style="color:rgb(0,128,128);font-weight:bold">"</span><span style="color:rgb(0,0,128);font-weight:bold">\\</span><span style="color:rgb(0,128,128);font-weight:bold">b"</span>), keyword)<br> <span style="color:rgb(0,0,128);font-weight:bold">for </span>key <span style="color:rgb(0,0,128);font-weight:bold">in </span>listKeywords<br> ]<br> <span style="color:rgb(0,0,128);font-weight:bold">for </span>rule <span style="color:rgb(0,0,128);font-weight:bold">in </span><span style="color:rgb(148,85,141)">self</span>.highlightingRules:<br> expression = QtCore.QRegExp(rule.pattern)<br> index = expression.indexIn(self.SearchResults.toPlainText())<br><br> <span style="color:rgb(0,0,128);font-weight:bold">while </span>index >= <span style="color:rgb(0,0,255)">0</span>:<br> length = expression.matchedLength()<br> <span style="color:rgb(148,85,141)">self</span>.setFormat(index, length, rule.format)<br> index = expression.indexIn(self.SearchResults.toPlainText(), index + length)<br><br></pre></blockquote></blockquote></div></div></div></div></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Sun, Sep 16, 2018 at 12:17 PM Maziar Parsijani <<a href="mailto:maziar.parsijani@gmail.com" target="_blank">maziar.parsijani@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr"><div>Hi Michael,<br></div><div>I attached an example file on this post,But I summarized the part that I want to work on it.I retrieve data from sqlite and set it into textedit and here I have just added 2 strings in it.for addition I have to say my data is Arabic text.before this I have found a way to compile the exact thing to highlight but now the problem is the low speed with more data. <br></div><div>Thanks for your advice about profiling codes.<br></div></div></div><br><div class="gmail_quote"><div dir="ltr">On Sun, Sep 16, 2018 at 8:00 AM michael h <<a href="mailto:michaelkenth@gmail.com" target="_blank">michaelkenth@gmail.com</a>> wrote:<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="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><pre style="background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:"DejaVu Sans Mono";font-size:9.1pt">doc.setDefaultStyleSheet(<font face="monospace, monospace"><span class="highlight">found</span></font>)<br><code><span class="m_-9111560529859349795m_-6014505165040928620m_-7225432585895105533m_2058158689121283743gmail-pln"></span></code></pre></div></div></div></div></div></div></div></div></div></blockquote><div>This is where the css rules go, not the html</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><pre style="background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:"DejaVu Sans Mono";font-size:9.1pt"><code><span class="m_-9111560529859349795m_-6014505165040928620m_-7225432585895105533m_2058158689121283743gmail-pln">doc</span><span class="m_-9111560529859349795m_-6014505165040928620m_-7225432585895105533m_2058158689121283743gmail-pun">.</span><span class="m_-9111560529859349795m_-6014505165040928620m_-7225432585895105533m_2058158689121283743gmail-pln">setHtml()<br></span></code><br></pre></div></div></div></div></div></div></div></div></div></blockquote><div>this would be where you set the html</div><div><br></div><div><br></div><div>Aside from that:</div><div><br></div><div>- Profile the code because the issue may not be where you expect it</div><div>- You might look into using QSyntaxHighlighter, which would allow you to highlight without inserting HTML markup.</div><div>- If you could post a self contained runnable example I'd take a closer look<br></div></div></div>
</blockquote></div>
</blockquote></div>