everyone. I have a text written on my textEdit. When I click a button, I want to highlight the text with a background color, without loosing the information about the font, the color ect. I've tried with the following code:
QTextCursor curs=ui->textEdit->textCursor();
QTextCharFormat fmt=curs.charFormat();
fmt.setBackground(Qt::yellow);
curs.setCharFormat(fmt);
ui->textEdit->setTextCursor(curs);
but it doesn't work. Can you help me? Thanks