QTableWidget:不同的样式在*一* QTableWidgetItem? [英] QTableWidget: different styles in *one* QTableWidgetItem?
问题描述
在QTableWidget的单元格(QTableWidgetItem)中是否可以有一个双行元素,每行有不同的样式?我想让第一行粗体和第二行不是粗体。或者我可以在一个单元格中添加两个QTableWidgetItems?以某种方式执行单元格?
Is it possible to have a two-line element in a cell (QTableWidgetItem) of a QTableWidget with different styles per line? I want to have the first line bold and the second line not bold. Or can I add two QTableWidgetItems in one cell? Do a cellspan somehow?
干杯
Matthias
Cheers Matthias
推荐答案
简单方法:
检查 setCellWidget 方法的QTableWidget。
Checkout the setCellWidget method of QTableWidget.
如果您将 QTextEdit ,您可以获得富文本格式化功能。
If you replace the default widget with QTextEdit, you can get rich text formatting capability.
更好的方式:
自定义QStyledItemDelegate。您可以查看此处示例
Use a custom QStyledItemDelegate. You can see an example here
我希望这有助于。
这篇关于QTableWidget:不同的样式在*一* QTableWidgetItem?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!