Pyqt:如何最大化表格视图中的列宽? [英] Pyqt: How to maximize the column width in a tableview?

查看:42
本文介绍了Pyqt:如何最大化表格视图中的列宽?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

实际上标题包含了所有需要的信息.是否有一个像 tableview.resizeColumnsToContents() 这样的简单函数,它允许在小部件大小内最大化所有列宽?我的列很窄,所以表格看起来很紧凑.

Actually the title contains all information needed. Is there an easy function like tableview.resizeColumnsToContents() that allows the maximization of all column widths within the widget size? My columns are narrow so the table looks very compact.

推荐答案

如果你想要列均匀扩展,你也可以设置resize mode

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

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

在 pyqt5 中 setResizeMode 不再可用.相反,在 QtWidgets 模块中使用 setSectionResizeModeQHeaderView.

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

这篇关于Pyqt:如何最大化表格视图中的列宽?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆