Question

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

Was it helpful?

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.

OTHER TIPS

What you're looking at isn't a QListView object. That's a QTreeWidget.

To add a new "column", you need to modify the header using QTreeWidget.setHeader(). Top-level items are added using QTreeWidget.addTopLevelItem().

You can find Qt's documentation for this element here: http://doc.qt.nokia.com/latest/qtreewidget.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top