问题
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