我使用的是 PyQt4,这段代码运行良好.
I was using PyQt4 and this code works great.
self.table.horizontalHeader().setResizeMode(1, QHeaderView.Stretch)
它正在拉伸表格中的一列.但是当我用 PyQt5 运行代码时,我得到了这个错误:
It's stretching a column in a table. But when I run the code with PyQt5, I'm getting this error:
Attribute Error: 'QHeaderView' object has no attribute 'setResizeMode'
你能帮忙吗?或者简单地说;如何在 PyQt5 中调整任何列?
Can you please help? Or simply; how can I strect any column in PyQt5?
使用 QHeaderView.setSectionResizeMode 而不是 QHeaderView.setResizeMode一个>:
改用 setSectionResizeMode.
Use setSectionResizeMode instead.
(引用文档 QHeaderView.setResizeMode)
这篇关于PyQt4 代码在 PyQt5 (QHeaderView) 上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
如何将函数绑定到 Qt 菜单栏中的操作?How to bind a function to an Action from Qt menubar?(如何将函数绑定到 Qt 菜单栏中的操作?)
PyQt 启动后进度跃升至 100%PyQt progress jumps to 100% after it starts(PyQt 启动后进度跃升至 100%)
如何将 yaxis 刻度标签设置在固定位置,以便当我How to set yaxis tick label in a fixed position so that when i scroll left or right the yaxis tick label should be visible?(如何将 yaxis 刻度标签设
`QImage` 构造函数有未知关键字 `data``QImage` constructor has unknown keyword `data`(`QImage` 构造函数有未知关键字 `data`)
将 x 轴刻度更改为自定义字符串Change x-axis ticks to custom strings(将 x 轴刻度更改为自定义字符串)
如何在python中将文件保存为excel时显示进度条?How to show progress bar while saving file to excel in python?(如何在python中将文件保存为excel时显示进度条?)