Ciasto piekarz
Ciasto piekarz

Reputation: 8277

How to get the selectionchange event in PyQt4 for QListView

Hi have a QListView created using QtDesigner and converted to python using pyuic4, and I imported the UI module where I am trying to connect it to events

for the QlistView i am trying to implement selection change when user presses up and down key, I am guessing the event should be fired when selection changes but that doesn't seems to do something

self.methodListView.selectionModel.selectionChanged.connect(self.outputHelp)

but this gives error

AttributeError: 'builtin_function_or_method' object has no attribute 'selectionChanged'

Do I need to add some more information to show exactly what I am doing?

Upvotes: 6

Views: 6103

Answers (1)

mata
mata

Reputation: 69092

self.methodListView.selectionModel isn't an attribute, it's a function which returns the selection model. Just use

self.methodListView.selectionModel().selectionChanged.connect(self.outputHelp)

and it should work...

Upvotes: 7

Related Questions