Home > Mobile > Qt5 QTextEdit how to set the paragraph different background color
Qt5 QTextEdit how to set the paragraph different background color
Time:09-24
Background: there are Q3TextEdit qt3: : setParagraphBackgroundColor, but qt5 canceled,
Increasing demand: qtextedit in append mode paragraphs of text, to set the background color, the paragraph but how to set up the paragraph different background color?
Try: No effect in setTextBackgroundColor 2. Use setStyleSheet (" QLineEdit {background - color: black; } "); Whole set the background color, the only way not segmented 3. Use QPalette: : Base again setPalette also only whole set the background color, can't block
CodePudding user response:
You can use QTextBrowser QTextEdit instead, QTextBrowser can set HTML text style, more in line with your requirements,
CodePudding user response:
Can try listwidget or listview, each line color can be set directly
CodePudding user response:
Set the HTML, through HTML to control the color
CodePudding user response:
Can also use the inserted way insertHtml
CodePudding user response:
Above is a piece of HTML content, and the other one is effect, according to the color of the two HTML (light blue and red) should be different, but the display is light blue, what is the problem?
CodePudding user response:
To learn
CodePudding user response:
One way is to modify the current font background, eg: