Reputation: 37
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?
Upvotes: 2
Views: 249
Reputation: 243897
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_())
Upvotes: 1