Important: Please read the Qt Code of Conduct -

QPlainTextEdit - Different color for paragraphs

  • Hello,

    I've searched all questions on this forum about QPlainTextEdit, but i didn't found anything about setting a color for every paragraph.

    In Docs, is written that " Each character within a paragraph has its own attributes, for example, font and color."

    But no info about how to set font and color.

    I use

    void QPlainTextEdit::appendPlainText ( const QString & text )

    to append text, ans i need a different color for every string that i append.

    I need QPlainTextEdit because it's good for logs, or big amount of text, and I need to do a colored log for my program.

    p.s. tried to set palette with different color before appending, but it simply change the color of entire text.

    Any suggestions are welcome.



  • You could use "appendHtml":

    bq. Appends a new paragraph with html to the end of the text edit.

  • Thanks, it works : )

Log in to reply