QTableWidget:不同的样式在*一* QTableWidgetItem? [英] QTableWidget: different styles in *one* QTableWidgetItem?

查看:962
本文介绍了QTableWidget:不同的样式在*一* 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆