2

enter image description here

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?

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
xwsz
  • 37
  • 2

1 Answers1

1

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_())

enter image description here

eyllanesc
  • 235,170
  • 19
  • 170
  • 241