When you get the selection model you have to take ownership of it. Therefore you do have to keep a reference to it in your own code. Qt's doc gives some information about it...
Now I remember that there was a bug with that, where the ownership was not correctly passed to the caller. This bug came and go and came again. Right now, I've redefined QTableView like this : from PySide.QtGui import QTableView class QTableView(QTableView): def __init__(self,parent=None): super(QTableView,self).__init__(parent) self._selection_model = None def setModel(self,model): super(QTableView,self).setModel(model) self._selection_model = super(QTableView,self).selectionModel() def selectionModel(self): return self._selection_model and so far it has worked perfectly (I have an application in production since 2 months, used 8 hours a day by 4-5 persons that makes extensive use of selection models) Stefan > Le 16 janvier 2014 à 12:53, Andy Kittner <[email protected]> a écrit : > > > On 16.01.2014 11:50, Alexey Vihorev wrote: > > Hi! > > > > I’ve got a problem trying to connect currentChanged/selectedChanged signals > > to anything. The code: > I vaguely remember having a similar problem once (it's ages ago so > things might have changed). > After some debugging I found that the object providing the slot was garbage > collected before the connection was made resulting in the crash. > > > Can you try changing this > > > self.view.selectionModel().currentChanged.connect(self.handler) > > To the following: > > selection_model = self.view.selectionModel() > selection_model.currentChanged.connect(self.handler) > > And see if that helps? > > Regards, > Andy > _______________________________________________ > PySide mailing list > [email protected] > http://lists.qt-project.org/mailman/listinfo/pyside _______________________________________________ PySide mailing list [email protected] http://lists.qt-project.org/mailman/listinfo/pyside
