python - Qtablewidget去除黑色空间PyQt5

标签 python python-3.x qt pyqt5

我正在尝试删除QTableWidget中的冗余空间。我正在使用 PyQt5。

这是代码

    self.tableWidget = QtWidgets.QTableWidget(self.centralwidget)
    self.tableWidget.setGeometry(QtCore.QRect(10, 10, 500, 351))
    self.tableWidget.setRowCount(5)
    self.tableWidget.setColumnCount(3)

    self.tableWidget.setHorizontalHeaderLabels(["name", "pass", "Id" ])
    self.tableWidget.setObjectName("tableWidget")

您可以在下图中看到问题。

enter image description here

最佳答案

您需要使用stretchLastSection属性(property)

 self.tableWidget.horizontalHeader().setStretchLastSection(True);

关于python - Qtablewidget去除黑色空间PyQt5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49773685/

相关文章:

python - 标签的 BeautifulSoup 值返回 None 即使存在值并且找到了标签 python

python - 从 Python 执行存储过程

Python:调整窗口大小时调整小部件的大小(使用 PLACE 管理器)

python - Mongoengine:查询 MapField

c++ - 如何根据用户输入动态更改任何项目的位置?

python - 30 秒超时后,从 Heroku 流式传输大文件失败

python - 在 64 位 Windows 上让 cython 与 Enthought Canopy 配合使用的官方方法是什么?

Python-使用凭据从 ftp url 中提取 csv

c++ - 我可以在 QDomDocument 中找到所有具有给定属性的 XML 节点吗?

c++ - 这是什么语法 : "ACGT"[(int)qrand() % 4]