Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 345
Ciasto piekarz Avatar asked Oct 26 '13 09:10

Ciasto piekarz


1 Answers

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...

like image 66
mata Avatar answered Oct 19 '22 19:10

mata