如何通过CSS设置QTableView单元格的填充? [英] How to set the padding of QTableView cells through CSS?

查看:387
本文介绍了如何通过CSS设置QTableView单元格的填充?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以定义QTableView单元格的填充?我希望这可以使用CSS样式表,但文档没有描述一个方法来做到这一点。

Is it possible to define the padding of QTableView cells? I would expect this to be possible using CSS stylesheets, but the documentation does not describe a method to do this.

以下样式表没有所需的效果:

The following stylesheet does not have the desired effect:

QTableView {
  padding: 5px;
}

,因为它会影响窗口小部件的整体填充属性,个别单元格。

as it influences the padding property of the widget as a whole, not of the individual cells.

推荐答案

我知道这是一个老问题,但我最近一直在努力。

I know this is an old question but I've been struggling with this recently.

我发现通过设置

tableView-> verticalHeader() - > setSectionResizeMode(QHeaderView :: ResizeToContents);

tableView->verticalHeader()->setSectionResizeMode(QHeaderView::ResizeToContents);

CSS中的填充集将被应用于单元格的顶部和底部。

the padding set in your CSS will then be applied to the top and bottom of the cell, too!

这篇关于如何通过CSS设置QTableView单元格的填充?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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