QTableWidget: different styles in *one* QTableWidgetItem?

人盡茶涼 提交于 2019-12-11 04:32:09

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/6438447/qtablewidget-different-styles-in-one-qtablewidgetitem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!