How to customize QTableWidget through stylesheet?

跟風遠走 提交于 2019-12-08 11:23:05

问题


I'm trying to customize a QTableWidget through stylesheet and I'm only limited to the items descibed here.

How do I change the spacing in the horizontal header of the table, the size of its header label, the spaces between the columns, et al?


回答1:


You should use QAbstractItemDelegate to control display of items in QTableWidget.

From explanation of delegates:

"Unlike the Model-View-Controller pattern, the model/view design does not include a completely separate component for managing interaction with the user. Generally, the view is responsible for the presentation of model data to the user, and for processing user input. To allow some flexibility in the way this input is obtained, the interaction is performed by delegates. These components provide input capabilities and are also responsible for rendering individual items in some views. The standard interface for controlling delegates is defined in the QAbstractItemDelegate class."

From QTableWidget::setItemDelegate():

"Sets the item delegate for this view and its model to delegate. This is useful if you want complete control over the editing and display of items."

And for an example : pixelator.



来源:https://stackoverflow.com/questions/5418304/how-to-customize-qtablewidget-through-stylesheet

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