开发者

QTableWidget: different styles in *one* QTableWidgetItem?

开发者 https://www.devze.com 2023-03-15 02:07 出处:网络
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 t

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?

Cheers 开发者_开发问答Matthias


Simple way :

Checkout the setCellWidget method of QTableWidget.

If you replace the default widget with QTextEdit, you can get rich text formatting capability.

Better way :

Use a custom QStyledItemDelegate. You can see an example here

I hope this helps.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号