Change text color of one word in QMessageBox message
Below is a few lines of code from a QMessageBox message. I want ONLY the word FREE to appear in red. Possible?
I tried: <font color = red> just before FREE and then </font> just after the word FREE, but it did not work (it just printed the words <font color = red> and </font>
Code:
box.setText("*************************************************"
"\n A FREE update is available."
"\n*************************************************"
Thanks
Re: Change text color of one word in QMessageBox message
Read up on Qt's Rich Text format and the subset of HTML it supports. But you do have to write correct HTML:
Code:
<font color="red">blah, blah, blah</font>
Qt widgets that support Rich Text usually will auto-detect it, but you can force it by setting the textFormat() to Qt:: RichText.