There's always an bland area at the bottom of the tableview of QTableWidget.
How can I get rid of this blank area, and let the tableview only display the row and column according to the given data?
There's always an bland area at the bottom of the tableview of QTableWidget.
How can I get rid of this blank area, and let the tableview only display the row and column according to the given data?
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_())