I have a QTextEdit window that shows the content of a file. I would like to be able to find all matches inside the text using a regex and highlight them either by making the match background different or by changing the match text color or making it bold. How can I do this?
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- QML: Cannot read property 'xxx' of undefin
- How to get the background from multiple images by
- Evil ctypes hack in python
Here is a sample of how can you highlight text in a
QTextEdit
:I think the simplest solution to your problem is to use the cursor associated to your editor in order to do the formatting. This way you can set the foreground, the background, the font style... The following example marks the matches with a different background.
The code is self-explanatory but if you have any questions just ask them.