Need help getting QAbstractItemView syntax correct
Hi,
I can't figure out how to properly connect an instance of a QAbstractItemView to a signal. I've tried all kinds of different things based on bits that I've read but have yet to stumble on the magic formula.
What I'm trying to do is connect the arrow keys to a QTreeView so that when the user scrolls up and down the tree then another function is called. Based on what I've read the proper way to do this is through using the QAbstractItemView and connect to selectionModel().
Here's my latest version:
treeModel = self.ui.areaTree.selectionModel()
QtCore.QObject.connect(treeModel, QtCore.SIGNAL(QtGui.QAbstractItemView.CursorAction ), self.keyPress)
I'm using Python and PyQt4. I've broken out the treeModel just to make sure I had accessed it properly. Can someone please point out the proper code.
Thanks
Re: Need help getting QAbstractItemView syntax correct
QAbstractItemView is a abstract class.. you will need to inherit that class or use some other classes such as QlistView, QTreeView or QTableview in order to use it properly.
Re: Need help getting QAbstractItemView syntax correct
I thought I had inherited it with treeModel when I grabbed selectionModel() from the Tree Widget. I thought that QAbstractItemView <- QTreeView <- QTreeWidget, so selectionModel gives you an extenstion of the view. Is that not correct?
If not could you point me to an example where it is used correctly.
Thanks
Re: Need help getting QAbstractItemView syntax correct
The model doesn't have the view's signals. You are trying to connect a signal defined in the view class using a model object. You have to at least change treeModel = self.ui.areaTree.selectionModel() to treeModel = self.ui.areaTree.