Sorry, no sucess here. I don't get it. Peter
On Mit, 2008-01-23 at 18:28 +0100, David Boddie wrote: > On Wed Jan 23 17:08:15 GMT 2008, Peter Liedler wrote: > > > I am still fighting to get connected to a selectionChanged signal of a > > listView. > > I think there's been some confusion about what actually emits the > selectionChanged() signal. It's actually the list view's selection model: > > http://www.riverbankcomputing.com/Docs/PyQt4/html/qabstractitemview.html#selectionModel > > The signal is described here: > > http://www.riverbankcomputing.com/Docs/PyQt4/html/qitemselectionmodel.html#selectionChanged > > > If I understand the qt documentation, the QItemSelection is generated > > automatically by filling the index to the model and defining the model > > to the list. > > I'm not sure what you mean. The selection model (which is set up by the view) > keeps track of the selected indexes in the model. > > > I think I do so by: > > > > Defining the model class: > > > > class myListModel(QAbstractListModel): > > def __init__(self, datain, parent=None, *args): > > """ datain: a list where each item is a row > > """ > > QAbstractTableModel.__init__(self, parent, *args) > > self.listdata = datain > > This looks OK. > > > In the main view I call a subfunction to set the index to the model: > > > > self.listModel = myListModel(TitleTrack, self) > > > > #init listView > > self.listViewTitleFill() > > > > Where TitleTrack is a python list. > > So, you're putting data into the model. > > > def listViewTitleFill(self): > > """ init ListViews and build list models """ > > self.listModel = myListModel(TitleTrack, self) > > self.listViewTitle.setModel(self.listModel) > > self.listViewTitle.setSelectionMode( > > QAbstractItemView.SingleSelection) > > > > This part works fine. The list is filled and I can select items in > > there. > > OK. You're defining the model again here, of course... > > Now, this is the problem part: > > > self.connect(self.listViewTitle, > > SIGNAL("selectionChanged(QItemSelection, QItemSelection)"), > > self.titleSelected) > > > > With this connect string I try to connect to the signal that is emitted > > when the selection is changed. But it is never called. > > What am I missing here. > > You need to connect the selection model's signal to the titleSelected() slot: > > self.connect(self.listViewTitle.selectionModel(), > SIGNAL("selectionChanged(QItemSelection, QItemSelection)"), > self.titleSelected) > > Does that work? > > David _______________________________________________ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt