如何通过样式表自定义 QTableWidget? [英] How to customize QTableWidget through stylesheet?

查看:82
本文介绍了如何通过样式表自定义 QTableWidget?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过样式表自定义 QTableWidget 并且我仅限于描述的项目 此处.

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?

推荐答案

你应该使用 QAbstractItemDelegate 控制 QTableWidget 中项目的显示.

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

来自代表的解释:

"与模型-视图-控制器模式不同,模型/视图设计不包括一个完全独立的组件来管理与用户的交互.通常,视图负责将模型数据呈现给用户,并为处理用户输入.为了让这种输入的获取方式具有一定的灵活性,交互由委托执行.这些组件提供输入功能,还负责呈现单个项目在某些视图中.控制委托的标准接口在 QAbstractItemDelegate 类中定义."

"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."

来自 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."

例如:pixelator.

这篇关于如何通过样式表自定义 QTableWidget?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆