Search code examples
pythonpyqt4qlistview

Python: Qt4: 'QListView' object has no attribute 'addColumn'


For some weird reason this QListView object doesn't have addColumn attribute. Could you explain what I'm doing wrong here ?

self.pointListBox = QtGui.QListView(self)

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

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

Eventually, I'm trying to get a simple QListView working exactly similar to this one. In Python!

                               image


Solution

  • You are referring to functionality of a QListView from the older Qt3, which did have the addColumn() method: http://doc.qt.nokia.com/3.3/qlistview.html

    But you are using Qt4 / PyQt4, which is not the same API: http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qlistview.html

    I recommend you find an updated tutorial/guide to work from or pick up a modern PyQt4 book.