<div dir="ltr">Well of course I am not OK with the code that I sent.And as I said the font and alignment are important to me.<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Aug 20, 2018 at 10:59 PM, Maurizio Berti <span dir="ltr"><<a href="mailto:maurizio.berti@gmail.com" target="_blank">maurizio.berti@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">In my opinion, if I may, it seems a bit too complex and elaborate than it could be, and seems to be even more prone to error; for instance, it's not clear why you init a new QStyleOptionViewItem, while you can just initStyleOption the one from the paint argument, and the use of PaintContext is missing important state cases (focus/active, enabled, hover, etc). But, if it works for you, that's fine :-)<br><br><div>About the size, since you are not using character distinction (bold/italic), you could use QFontMetrics (that will not take kerning into account, obviously) with its width or boundingRect methods.<br>If you are interested in width only, I suppose QTextDocument's textWidth should be fine also, but I actually never used for this kind of situations.<div><br></div><div>If alignment is an issue, you should be able to fix those data with QStyleOption's displayAlignment, along with QWidget's layoutDirection and QLocale settings, but I suppose you already know that.</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>Maurizio</div></font></span></div></div><div class="HOEnZb"><div class="h5"><br><div class="gmail_quote"><div dir="ltr">Il giorno lun 20 ago 2018 alle ore 18:58 Maziar Parsijani <<a href="mailto:maziar.parsijani@gmail.com" target="_blank">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>Here I think Maurizio code will functioning like this :<br><pre style="background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:"DejaVu Sans Mono";font-size:9.1pt"><span style="color:rgb(0,0,128);font-weight:bold">from </span>PyQt5 <span style="color:rgb(0,0,128);font-weight:bold">import </span>QtCore, QtGui, QtWidgets<br><span style="color:rgb(0,0,128);font-weight:bold">import </span>random<br><span style="color:rgb(0,0,128);font-weight:bold">import </span>html<br><br>words = [<span style="color:rgb(0,128,128);font-weight:bold">"Hello"</span>, <span style="color:rgb(0,128,128);font-weight:bold">"world"</span>, <span style="color:rgb(0,128,128);font-weight:bold">"Stack"</span>, <span style="color:rgb(0,128,128);font-weight:bold">"Overflow"</span>, <span style="color:rgb(0,128,128);font-weight:bold">"Hello world"</span>, <span style="color:rgb(0,128,128);font-weight:bold">"""<font color="red">Hello world</font>"""</span>]<br><br><br><span style="color:rgb(0,0,128);font-weight:bold">class </span>HTMLDelegate(QtWidgets.<wbr>QStyledItemDelegate):<br>    <span style="color:rgb(0,0,128);font-weight:bold">def </span><span style="color:rgb(178,0,178)">__init__</span>(<span style="color:rgb(148,85,141)">self</span>, parent=<span style="color:rgb(0,0,128);font-weight:bold">None</span>):<br>        <span style="color:rgb(0,0,128)">super</span>(HTMLDelegate, <span style="color:rgb(148,85,141)">self</span>).<span style="color:rgb(178,0,178)">__init__</span>(parent)<br>        <span style="color:rgb(148,85,141)">self</span>.doc = QtGui.QTextDocument(<span style="color:rgb(148,85,141)">self</span>)<br><br>    <span style="color:rgb(0,0,128);font-weight:bold">def </span>paint(<span style="color:rgb(148,85,141)">self</span>, painter, option, index):<br>        substring = index.data(QtCore.Qt.UserRole)<br>        painter.save()<br>        options = QtWidgets.<wbr>QStyleOptionViewItem(option)<br>        <span style="color:rgb(148,85,141)">self</span>.initStyleOption(options, index)<br>        <span style="color:rgb(128,128,128)">res </span>= <span style="color:rgb(0,128,128);font-weight:bold">""<br></span><span style="color:rgb(0,128,128);font-weight:bold">        </span>color = QtGui.QColor(<span style="color:rgb(0,128,128);font-weight:bold">"orange"</span>)<br>        <span style="color:rgb(0,0,128);font-weight:bold">if </span>substring:<br>            substrings = options.text.split(substring)<br>            res = <span style="color:rgb(0,128,128);font-weight:bold">"""<font color="{}">{}</font>"""</span>.<wbr>format(<a href="http://color.name" target="_blank">color.name</a>(QtGui.<wbr>QColor.HexRgb), substring).join(<span style="color:rgb(0,0,128)">list</span>(<span style="color:rgb(0,0,128)">map</span>(html.<wbr>escape, substrings)))<br>        <span style="color:rgb(0,0,128);font-weight:bold">else</span>:<br>            res = html.escape(options.text)<br>        <span style="color:rgb(148,85,141)">self</span>.doc.setHtml(res)<br><br>        options.text = <span style="color:rgb(0,128,128);font-weight:bold">""<br></span><span style="color:rgb(0,128,128);font-weight:bold">        </span>style = QtWidgets.QApplication.style() <span style="color:rgb(0,0,128);font-weight:bold">if </span>options.widget <span style="color:rgb(0,0,128);font-weight:bold">is None </span>\<br>            <span style="color:rgb(0,0,128);font-weight:bold">else </span>options.widget.style()<br>        style.drawControl(QtWidgets.<wbr>QStyle.CE_ItemViewItem, options, painter)<br><br>        ctx = QtGui.<wbr>QAbstractTextDocumentLayout.<wbr>PaintContext()<br>        <span style="color:rgb(0,0,128);font-weight:bold">if </span>option.state & QtWidgets.QStyle.State_<wbr>Selected:<br>            ctx.palette.setColor(QtGui.<wbr>QPalette.Text, option.palette.color(<br>                QtGui.QPalette.Active, QtGui.QPalette.<wbr>HighlightedText))<br>        <span style="color:rgb(0,0,128);font-weight:bold">else</span>:<br>            ctx.palette.setColor(QtGui.<wbr>QPalette.Text, option.palette.color(<br>                QtGui.QPalette.Active, QtGui.QPalette.Text))<br><br>        textRect = style.subElementRect(<br>            QtWidgets.QStyle.SE_<wbr>ItemViewItemText, options)<br><br>        <span style="color:rgb(0,0,128);font-weight:bold">if </span>index.column() != <span style="color:rgb(0,0,255)">0</span>:<br>            textRect.adjust(<span style="color:rgb(0,0,255)">5</span>, <span style="color:rgb(0,0,255)">0</span>, <span style="color:rgb(0,0,255)">0</span>, <span style="color:rgb(0,0,255)">0</span>)<br><br>        thefuckyourshitup_constant = <span style="color:rgb(0,0,255)">4<br></span><span style="color:rgb(0,0,255)">        </span>margin = (option.rect.height() - options.fontMetrics.height()) // <span style="color:rgb(0,0,255)">2<br></span><span style="color:rgb(0,0,255)">        </span>margin = margin - thefuckyourshitup_constant<br>        textRect.setTop(textRect.top() + margin)<br><br>        painter.translate(textRect.<wbr>topLeft())<br>        painter.setClipRect(textRect.<wbr>translated(-textRect.topLeft()<wbr>))<br>        <span style="color:rgb(148,85,141)">self</span>.doc.documentLayout().<wbr>draw(painter, ctx)<br><br>        painter.restore()<br><br><br>    <span style="color:rgb(0,0,128);font-weight:bold">def </span>sizeHint(<span style="color:rgb(148,85,141)">self</span>, option, index):<br>        <span style="color:rgb(0,0,128);font-weight:bold">return </span>QSize(<span style="color:rgb(148,85,141)">self</span>.doc.idealWidth(), <span style="color:rgb(148,85,141)">self</span>.doc.size().height())<br><br><span style="color:rgb(0,0,128);font-weight:bold">class </span>Widget(QtWidgets.QWidget):<br>    <span style="color:rgb(0,0,128);font-weight:bold">def </span><span style="color:rgb(178,0,178)">__init__</span>(<span style="color:rgb(148,85,141)">self</span>, parent=<span style="color:rgb(0,0,128);font-weight:bold">None</span>):<br>        <span style="color:rgb(0,0,128)">super</span>(Widget, <span style="color:rgb(148,85,141)">self</span>).<span style="color:rgb(178,0,178)">__init__</span>(parent)<br>        hlay = QtWidgets.QHBoxLayout()<br>        lay = QtWidgets.QVBoxLayout(<span style="color:rgb(148,85,141)">self</span>)<br><br>        <span style="color:rgb(148,85,141)">self</span>.le = QtWidgets.QLineEdit()<br>        <span style="color:rgb(148,85,141)">self</span>.button = QtWidgets.QPushButton(<span style="color:rgb(0,128,128);font-weight:bold">"filter"</span><wbr>)<br>        <span style="color:rgb(148,85,141)">self</span>.table = QtWidgets.QTableWidget(<span style="color:rgb(0,0,255)">5</span>, <span style="color:rgb(0,0,255)">5</span>)<br>        hlay.addWidget(<span style="color:rgb(148,85,141)">self</span>.le)<br>        hlay.addWidget(<span style="color:rgb(148,85,141)">self</span>.button)<br>        lay.addLayout(hlay)<br>        lay.addWidget(<span style="color:rgb(148,85,141)">self</span>.table)<br>        <span style="color:rgb(148,85,141)">self</span>.button.clicked.connect(<span style="color:rgb(148,85,141)">se<wbr>lf</span>.find_items)<br>        <span style="color:rgb(148,85,141)">self</span>.table.setItemDelegate(<wbr>HTMLDelegate(<span style="color:rgb(148,85,141)">self</span>.table))<br><br>        <span style="color:rgb(0,0,128);font-weight:bold">for </span>i <span style="color:rgb(0,0,128);font-weight:bold">in </span><span style="color:rgb(0,0,128)">range</span>(<span style="color:rgb(148,85,141)">self</span>.table.rowCount()):<br>            <span style="color:rgb(0,0,128);font-weight:bold">for </span>j <span style="color:rgb(0,0,128);font-weight:bold">in </span><span style="color:rgb(0,0,128)">range</span>(<span style="color:rgb(148,85,141)">self</span>.table.columnCount()<wbr>):<br>                it = QtWidgets.QTableWidgetItem(<wbr>random.choice(words))<br>                <span style="color:rgb(148,85,141)">self</span>.table.setItem(i, j, it)<br><br>    <span style="color:rgb(0,0,128);font-weight:bold">def </span>find_items(<span style="color:rgb(148,85,141)">self</span>):<br>        text = <span style="color:rgb(148,85,141)">self</span>.le.text()<br>        <span style="color:rgb(128,128,128);font-style:italic"># clear<br></span><span style="color:rgb(128,128,128);font-style:italic">        </span>allitems = <span style="color:rgb(148,85,141)">self</span>.table.findItems(<span style="color:rgb(0,128,128);font-weight:bold">""</span>, QtCore.Qt.MatchContains)<br>        selected_items = <span style="color:rgb(148,85,141)">self</span>.table.findItems(<span style="color:rgb(148,85,141)">self</span>.le.<wbr>text(), QtCore.Qt.MatchContains)<br>        <span style="color:rgb(0,0,128);font-weight:bold">for </span>item <span style="color:rgb(0,0,128);font-weight:bold">in </span>allitems:<br>            item.setData(QtCore.Qt.<wbr>UserRole, text <span style="color:rgb(0,0,128);font-weight:bold">if </span>item <span style="color:rgb(0,0,128);font-weight:bold">in </span>selected_items <span style="color:rgb(0,0,128);font-weight:bold">else None</span>)<br><br><br><span style="color:rgb(0,0,128);font-weight:bold">if </span>__name__ == <span style="color:rgb(0,128,128);font-weight:bold">'__main__'</span>:<br>    <span style="color:rgb(0,0,128);font-weight:bold">import </span>sys<br>    app = QtWidgets.QApplication(sys.<wbr>argv)<br>    w = Widget()<br>    w.show()<br>    sys.exit(app.exec_())<br><br></pre><pre style="background-color:rgb(255,255,255);color:rgb(0,0,0);font-family:"DejaVu Sans Mono";font-size:9.1pt">But the main problem of this method as you said is changing in font size and aligning because my data's are Arabic and English.<br></pre></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Aug 20, 2018 at 7:15 PM, Maurizio Berti <span dir="ltr"><<a href="mailto:maurizio.berti@gmail.com" target="_blank">maurizio.berti@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I'm not an expert on regular expressions, maybe there's a better and faster approach than the one I used in the example.<div>I initially tried using re.sub, but works correctly only if you want to match case, as the substitution string is fixed.<br>Anyway, it seems fast enough to me, as the viewport update() takes care of repainting only visible elements.<br></div><div><br></div><div>Another (derivate) approach could be subclassing the model too (the data() method), adding a custom user role for the html filtered text that can be read by the delegate, maybe with some sort of caching in the model to speed up reading. It may be slightly faster and more "elegant" (the model takes care of the string match, not the delegate), and could be useful for further implementation.</div><div><br></div><div>I forgot to say: my example obviously doesn't consider spacings, grid lines pen width and icon decoration.</div><span class="m_1550169153494673832m_3168939307277646746HOEnZb"><font color="#888888"><div><br>Maurizio</div></font></span></div><div class="m_1550169153494673832m_3168939307277646746HOEnZb"><div class="m_1550169153494673832m_3168939307277646746h5"><br><div class="gmail_quote"><div dir="ltr">Il giorno lun 20 ago 2018 alle ore 16:01 Maziar Parsijani <<a href="mailto:maziar.parsijani@gmail.com" target="_blank">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><div>Really thanks to Maurizio<br></div>I will try this.I agree with you and was thinking if someone had a solution with re library and regix could be better for me .<br></div> <br></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Aug 20, 2018 at 6:09 PM, Maurizio Berti <span dir="ltr"><<a href="mailto:maurizio.berti@gmail.com" target="_blank">maurizio.berti@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I know you already found a solution, but I decided to give it a try anyway, just out of curiosity.<br>I didn't like the idea of using another QWidget, which might involve QStyle issues, then I found out that it's possible to use QTextDocument.<div>This is a simple implementation that just matches the text in all items (no actual search in the model).</div><div><br></div><div><br></div><div><div><font face="monospace, monospace">class MatchDelegate(QtWidgets.<wbr>QStyledItemDelegate):</font></div><div><font face="monospace, monospace">    regex = re.compile('')</font></div><div><font face="monospace, monospace"><div>    fakeIndex = QtCore.QModelIndex()</div><div><br></div></font></div><div><font face="monospace, monospace">    def paint(self, qp, option, index):</font></div><div><font face="monospace, monospace">        self.initStyleOption(option, index)</font></div><div><font face="monospace, monospace">        td = QtGui.QTextDocument()</font></div><div><font face="monospace, monospace">        if self.regex.pattern:</font></div><div><font face="monospace, monospace">            splitted = self.regex.split(option.text)</font></div><div><font face="monospace, monospace">            matches = iter(self.regex.findall(<wbr>option.text))</font></div><div><font face="monospace, monospace">            text = ''</font></div><div><font face="monospace, monospace">            for words in splitted[:-1]:</font></div><div><font face="monospace, monospace">                text += words + '<b>{}</b>'.format(matches.<wbr>next())</font></div><div><font face="monospace, monospace">            text += splitted[-1]</font></div><div><font face="monospace, monospace">        else:</font></div><div><font face="monospace, monospace">            text = option.text</font></div><div><font face="monospace, monospace">        td.setHtml(text)</font></div><div><font face="monospace, monospace">        option.text = ''</font></div><div><font face="monospace, monospace">        # Using an invalid index avoids painting of the text</font></div><div><font face="monospace, monospace">        QtWidgets.QStyledItemDelegate.<wbr>paint(self, qp, option, self.fakeIndex)</font></div><div><font face="monospace, monospace">        qp.save()</font></div><div><font face="monospace, monospace">        qp.translate(option.rect.<wbr>topLeft())</font></div><div><font face="monospace, monospace">        td.drawContents(qp, QtCore.QRectF(0, 0, option.rect.width(), option.rect.height()))</font></div><div><font face="monospace, monospace">        qp.restore()</font></div><div><br></div><div><span style="font-family:monospace,monospace;line-height:1.5"><br></span></div><div><span style="font-family:monospace,monospace;line-height:1.5">class Widget(QtWidgets.QWidget):</span><br></div></div><div><font face="monospace, monospace">    def __init__(self):</font></div><div><font face="monospace, monospace">        [...]</font></div><div><div style="font-family:monospace,monospace">        self.delegate = MatchDelegate()</div><div style="font-family:monospace,monospace">        self.table.setItemDelegate(<wbr>self.delegate)</div><div style="font-family:monospace,monospace"></div><div><font face="monospace, monospace">        self.search = QtWidgets.QLineEdit()</font></div><div><span style="font-family:monospace,monospace;line-height:1.5">        self.search.textChanged.<wbr>connect(self.findText)</span><br></div></div><div><font face="monospace, monospace"><div><div style="font-family:Arial,Helvetica,sans-serif"><font face="monospace, monospace">        [...]</font></div><div style="font-family:Arial,Helvetica,sans-serif"></div></div><div><div><br></div><div>    def findText(self, text):</div><div><span style="line-height:1.5">        self.delegate.regex = re.compile(text, re.I)</span><br></div><div>        self.table.viewport().update()</div></div></font></div><div><br></div><div><br></div><div>Of course it doesn't take the text size change into account whenever bold characters are in place, so the sizeHint is not perfect. Also, it might be possible to implement QFontMetrics' elidedText, again with some small issues about font size changes.<br></div><div><br></div><div>Maurizio</div><div><br></div></div><div><div class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058h5"><br><div class="gmail_quote"><div dir="ltr">Il giorno lun 20 ago 2018 alle ore 11:31 Maziar Parsijani <<a href="mailto:maziar.parsijani@gmail.com" target="_blank">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"><h3 class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960gmail-iw"><span name="Denis Rouzaud" class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960gmail-gD">Hi Denis Rouzaud</span></h3><p>This question was for 19days ago.But you are correct the best method is html delegate and I did it but I couldn't fix that with my table and the table was changed but it worked nice.<br></p></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Aug 20, 2018 at 12:28 PM, Denis Rouzaud <span dir="ltr"><<a href="mailto:denis.rouzaud@gmail.com" target="_blank">denis.rouzaud@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">This is not easily done.<div>You'd have to create a custom delegate using a QLabbel and use html in there.</div><div><br></div><div>I have been creating a search tool for tables and ending up highlighting the whole cell. </div><div>The effort and the risk of bad results is just not worth the effort IMHO.</div><div><br></div><div>Denis</div></div><br><div class="gmail_quote"><div><div class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960h5"><div dir="ltr">Le mar. 31 juil. 2018 à 23:05, Maziar Parsijani <<a href="mailto:maziar.parsijani@gmail.com" target="_blank">maziar.parsijani@gmail.com</a>> a écrit :<br></div></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960h5"><div dir="ltr"><div class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-post-text">

<p>I use method1 to find some text in qtablewidget rows.</p><p>
method1 :</p>

<pre class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-lang-py m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-prettyprint m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-prettyprinted"><code><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-kwd">def</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pln"> </span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-typ">FindItem</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pun">(</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pln">self</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pun">):</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pln">
    items </span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pun">=</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pln"> self</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pun">.</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-typ">SuraBRS</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pun">.</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pln">findItems</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pun">(</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pln">
        self</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pun">.</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-typ">SearchTbox</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pun">.</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pln">text</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pun">(),</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pln"> </span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-typ">QtCore</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pun">.</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-typ">Qt</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pun">.</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-typ">MatchContains</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pun">)</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pln">
    </span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-kwd">if</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pln"> items</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pun">:</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pln">
        results </span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pun">=</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pln"> </span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-str">'\n'</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pun">.</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pln">join</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pun">(</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pln">
            </span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-str">'row %d column %d'</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pln"> </span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pun">%</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pln"> </span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pun">(</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pln">item</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pun">.</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pln">row</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pun">()</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pln"> </span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pun">+</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pln"> </span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-lit">1</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pun">,</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pln"> item</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pun">.</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pln">column</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pun">()</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pln"> </span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pun">+</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pln"> </span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-lit">1</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pun">)</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pln">
            </span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-kwd">for</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pln"> item </span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-kwd">in</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pln"> items</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pun">)</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pln">
    </span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-kwd">else</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pun">:</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pln">
        results </span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pun">=</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pln"> </span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-str">'Found Nothing'</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pln">
    </span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-kwd">print</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pun">(</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pln">results</span><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064m_1845155414697011962gmail-pun">)</span></code></pre>

<p>Now I want to know how to highlight results or change their color.<strong>I want to select and highlight that text or character not all of the row or column</strong>.</p>
    </div></div></div></div>
______________________________<wbr>_________________<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.<wbr>riverbankcomputing.com/<wbr>mailman/listinfo/pyqt</a></blockquote></div><span class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960HOEnZb"><font color="#888888">-- <br><div dir="ltr" class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">





<p class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064inbox-inbox-inbox-inbox-p1"><span style="color:rgb(0,0,0);font-family:Verdana,sans-serif;font-size:10pt">Denis Rouzaud</span><br style="color:rgb(0,0,0);font-family:Times;font-size:medium"><a href="mailto:denis@opengis.ch" style="font-family:Times;font-size:medium" target="_blank"><span style="color:rgb(0,0,0);font-family:Verdana,sans-serif;font-size:8pt">denis@opengis.ch</span> </a><br style="color:rgb(0,0,0);font-family:Times;font-size:medium"><span style="color:rgb(0,0,0);font-family:Verdana,sans-serif;font-size:8pt"><a>+41 76 370 21 22</a></span></p><p class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372m_5740204084834526960m_5955850977701824064inbox-inbox-inbox-inbox-p1"><span style="color:rgb(0,0,0);font-family:Verdana,sans-serif;font-size:8pt"><a><br></a></span></p></div></div>
</font></span></blockquote></div><br></div>
______________________________<wbr>_________________<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.<wbr>riverbankcomputing.com/<wbr>mailman/listinfo/pyqt</a></blockquote></div><br clear="all"><div><br></div>-- <br></div></div><div dir="ltr" class="m_1550169153494673832m_3168939307277646746m_4271658922593434519m_6390428701510419058m_7375396995481516372gmail_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" target="_blank">http://www.jidesk.net</a></div>
</blockquote></div><br></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="m_1550169153494673832m_3168939307277646746m_4271658922593434519gmail_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" target="_blank">http://www.jidesk.net</a></div>
</div></div></blockquote></div><br></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="m_1550169153494673832gmail_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" target="_blank">http://www.jidesk.net</a></div>
</div></div></blockquote></div><br></div>