Changing the spacing between QTableView cells using stylesheet in PyQt5

喜夏-厌秋 提交于 2021-01-20 11:57:10

问题


How to add spaces between table cells using QSS selectors. I've tried the border-spacing selector, the item pseudo-class with the border selector, but it all doesn't work as it should.

Here is a sample code that I thought was supposed to do this.

app. setStyleSheet ("QTableView { border-collapse: separate; border-spacing: 10px 20px; color: red;}")

Here's a picture of what I mean.


回答1:


With style-sheets, you are either able to separate the individual cells via border-spacing (as in your example), or via padding:

app.setStyleSheet("QTableView::item { border:0px; padding: 150px; }")


来源:https://stackoverflow.com/questions/64930371/changing-the-spacing-between-qtableview-cells-using-stylesheet-in-pyqt5

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