Pyqt: How to maximize the column width in a tableview?

后端 未结 2 1273
情书的邮戳
情书的邮戳 2020-12-11 18:14

Actually the title contains all information needed. Is there an easy function like tableview.resizeColumnsToContents() that allows the maximization of all column widths with

相关标签:
2条回答
  • 2020-12-11 18:55

    If you want the columns to expand uniformly, you could also set the resize mode

    tableview.horizontalHeader().setResizeMode(QtGui.QHeaderView.Stretch)
    

    In pyqt5 setResizeMode is no longer available. Instead, use setSectionResizeMode and QHeaderView in the QtWidgets module.

    0 讨论(0)
  • 2020-12-11 18:57

    See resizeColumnsToContents.

    There's also a stretchLastSection property that can be used (see QTableView).

    0 讨论(0)
提交回复
热议问题