Get FontColor of QTextEdit Selection
I have an QTextEdit where i can set different Colors for the Text, but i didnt find any Method yet, to get the Color. I have a ComboBox to switch Colors and if i select a Textpart in the TextEdit i want to get the actuall Color.
Only Thing i found was QTextEdit.fontColor(), but that didnt work for selected Text in it.
You know what i mean? How can i get the actuall Color of the selected Text in QTextEdit?
QTextEdit::textColor()work for what you need?
Or you could always get it from
QTextEdit::toHtml(). That should contain the color information. Of course you'd have to parse for it.
Sorry i mean textColor(). The Problem is that this Method dont gets the Information from the selected Position in the TextEdit.
@Fuel Since you have a selection I'm assuming you have a QTextCursor for that in which case you could try
QTextCursor::charFormat()which you can then use to get the color using
Thats what im looking for, but here the Problem is that the Method name returns a #RRGGBB value and i need the name. Like Blue or Yellow.
I found a dirty Solution. i created a QPair Vector with String name of Color and #RRGGBB Value. Its not clean, but it works for my needs. If someone has an other Idea let me know.