Exchange Colors in QTextEdit
I have a QTextEdit that consists of multi colored content. The colors are defined in a settings file.
When I change the QTextEdit's style or apply new settings it should also repaint the old contents with the new colors.
How would I achieve that? Is there a method to repaint all text that has a certain color?
Or what is the best way to iterate over the existing text in order to repaint it?
It really depends what content is and how you colored it in first place.
if via HTML/rich text, you will have to recreate the html and change the colors
If you use cursor to loop over text blocks and change format, you will have to do so again.
I guess I will have to use QTextCharFormat to find out what the current color is?
Well if you are not constructing rich text with color codes so you can simply recreate with ne values, yes then you must use QCursor and QTextBlockFormat/Char to alter it
I did that and it worked without problems. thx