Python: Qt4: 'QListView' 对象没有属性 'addColumn'

标签 python pyqt4 qlistview

出于某种奇怪的原因,这个QListView对象没有addColumn属性。你能解释一下我在这里做错了什么吗?

self.pointListBox = QtGui.QListView(self)

self.pointListBox.addColumn("test")
self.pointListBox.addColumn("another")

self.pointLabelBox.QListViewItem(QString("derp"))

最终,我试图获得一个与此完全相似的简单 QListView 工作方式。在Python中!

                               image

最佳答案

您指的是旧版 Qt3 中 QListView 的功能,它确实有 addColumn() 方法:http://doc.qt.nokia.com/3.3/qlistview.html

但是您使用的是 Qt4/PyQt4,这不是同一个 API:http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qlistview.html

我建议您找到更新的教程/指南来工作或选择 modern PyQt4 book .

关于Python: Qt4: 'QListView' 对象没有属性 'addColumn',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11979561/

相关文章:

c++ - 多列列表的 Qt 最佳控件?

python - 如何在添加另一个字段时从数据框中传递嵌套的 JSON?

Python 脚本无法在 Linux 上运行

python - 使用 PyQt4,如何将 mouseMoveEvent 设置为仅在 QMainWindow 中的 QWidget 内部工作,但不在 MainWindow 中工作

python - 无法使用 PyQt4 中的 QProcess 放弃新进程的权限

c++ - QListView中的QT4 QstringListModel

python - 如何确定sshd的这个perl脚本的stdin内容

python - 将字典转换为值/元组列表

javascript - 如何解析 anchor 标记中的文本?

python - 如何使项目 View 在 PyQt 中呈现丰富的 (html) 文本?