[PyQt] [PYQT5]Highlight search results in qtablewidget(select and highlight that text or character not all of the row or column)

Maziar Parsijani maziar.parsijani at gmail.com
Mon Aug 20 10:29:54 BST 2018


Hi Denis Rouzaud

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.

On Mon, Aug 20, 2018 at 12:28 PM, Denis Rouzaud <denis.rouzaud at gmail.com>
wrote:

> This is not easily done.
> You'd have to create a custom delegate using a QLabbel and use html in
> there.
>
> I have been creating a search tool for tables and ending up highlighting
> the whole cell.
> The effort and the risk of bad results is just not worth the effort IMHO.
>
> Denis
>
> Le mar. 31 juil. 2018 à 23:05, Maziar Parsijani <
> maziar.parsijani at gmail.com> a écrit :
>
>> I use method1 to find some text in qtablewidget rows.
>>
>> method1 :
>>
>> def FindItem(self):
>>     items = self.SuraBRS.findItems(
>>         self.SearchTbox.text(), QtCore.Qt.MatchContains)
>>     if items:
>>         results = '\n'.join(
>>             'row %d column %d' % (item.row() + 1, item.column() + 1)
>>             for item in items)
>>     else:
>>         results = 'Found Nothing'
>>     print(results)
>>
>> Now I want to know how to highlight results or change their color.*I
>> want to select and highlight that text or character not all of the row or
>> column*.
>> _______________________________________________
>> PyQt mailing list    PyQt at riverbankcomputing.com
>> https://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
> --
>
> Denis Rouzaud
> denis at opengis.ch  <denis at opengis.ch>
> +41 76 370 21 22
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20180820/11289181/attachment.html>


More information about the PyQt mailing list