如何摆脱tableview底部的空白区域 [英] How to get rid of the blank area at the bottom of tableview
本文介绍了如何摆脱tableview底部的空白区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
QTableWidget 的 tableview 底部总是有一个平淡的区域.
There's always an bland area at the bottom of the tableview of QTableWidget.
如何去掉这个空白区域,让tableview只根据给定的数据显示行列?
How can I get rid of this blank area, and let the tableview only display the row and column according to the given data?
推荐答案
您必须将 Stretch
as resizeMode 设置为 verticalheader():
You have to set Stretch
as resizeMode to the verticalheader():
import sys
from PyQt5 import QtWidgets, QtCore, QtGui
if __name__ == '__main__':
app = QtWidgets.QApplication(sys.argv)
w = QtWidgets.QTableView()
w.setModel(QtGui.QStandardItemModel(4, 4))
w.verticalHeader().setSectionResizeMode(QtWidgets.QHeaderView.Stretch)
w.horizontalHeader().setSectionResizeMode(QtWidgets.QHeaderView.Stretch)
w.show()
sys.exit(app.exec_())
这篇关于如何摆脱tableview底部的空白区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文