在 QTextEdit C++ 中为特定行添加下划线
Underline specific line in QTextEdit C++
如何为QTextEdit的多个不同行添加下划线/更改颜色?这里找到的先前答案都没有帮助。它们都更改了所有QTextEdit行的颜色。
您可以使用setHtml(( 方法 (https://doc.qt.io/qt-5/qtextedit.html#html-prop( 来实现这样的外观。
对于特定的 QLineEdit,您可以使用QWidget::setStyle(QStyle *style)
要更改QLineEdit中的文本,只需使用样式即可。
看看这个: https://docs.huihoo.com/qt/5.x/stylesheet-examples.html
和这个:https://doc.qt.io/qt-5/stylesheet-reference.html
例如:
QLineEdit
{
border: 2px solid gray;
border-radius: 10px;
padding: 0 8px;
background: yellow;
border-bottom: 2px solid maroon;
selection-background-color: darkgray;
}
这是一个简单的例子,展示了如何在Qt中使用文本元素:
ui->textEdit->setText("this is a <a style='color:red;'>red</a> word!");
ui->textEdit->append("This is an <u>underlined</u> text.");
ui->textEdit->append("This is a <a style='color:red;'><u>red underlined</u></a>text.");
输出如下所示: 输出
相关文章:
- VSCode-有一个红色下划线,但程序构建和运行正确,并且出现配音错误
- 下划线不会与"发送输入"一起显示C++
- 在 QTextEdit C++ 中为特定行添加下划线
- 有什么理由不扩展 std::set 以添加下标运算符吗?
- 导出函数中有多少下划线('_')(C++
- 有没有选项不自动所有前导下划线 _ 以导出 emscripten 中的函数?
- 删除数字并在C++中保留字符串的下划线
- c++ 函数中额外的下划线名称
- 在C 中,Haskell下划线有其他选择吗?
- 使用与号后跟下划线命名的变量是什么意思?
- C++20 中的严格别名规则是否允许标准 c++ unicode 字符和下划线类型之间"reinterpret
- 用下划线填充空格
- 在Typedef结构中,下划线意味着什么
- 为什么非下划线名称保留给 UDL 的实现,而不是相反
- 下划线、名称和文字运算符
- 检查两个彼此相邻的两个下划线
- 使用查找检查,如果我的字符串中有下划线
- 代码的错误答案是在Java Camel案件和C 下划线标识符之间转换的错误答案
- 用户定义的文字、下划线和全局名称
- 为什么 VC++ 链接器会向入口点添加下划线