简体   繁体   中英

How to customize QTableWidget through stylesheet?

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?

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM