如何在 QLineEdit 中设置从索引 x(例如 x=10)到文本结尾的字符样式?
例子:
QLineEdit 中的文本:
0123456789
我想让从索引 2(即 2)到末尾的字符应该是粗体。
01 23456789
如何在 QLineEdit 中设置从索引 x(例如 x=10)到文本结尾的字符样式?
例子:
QLineEdit 中的文本:
0123456789
我想让从索引 2(即 2)到末尾的字符应该是粗体。
01 23456789
QLineedit
is a one line of plain text which you may not easily handle such character formatting. On the other hand Qt provides text widgets for plain and rich text, that can accept formatting such as html. For instance the QTextEdit
widget can be used and render such formatting of text with html tags.
QString html = "01<b>23456789</b>";
QTextEdit::setHtml(html);