Hello!
I wrote a little snippet to demonstrate a tableview with the slot you
wanted and how to disconnect it. Please note, that this code is reduced
to the minimum and therefor will not win the Miss Code 2011 award... But
I hope, it shows you the possibility. To show, that the slot works, I
first connect for 5 seconds (so select an item quickly) and then
disconnect it after using a timer. You used "the old" signal/slot
syntax. I used the new one, I think this is more pythonic and readable:
view.selectionModel().currentChanged.disconnect(slot)
Hope it helps!
Aaron
from PySide.QtGui import *
from PySide.QtCore import *
from PySide.QtSql import *
import sys
class TableModel(QAbstractTableModel):
def __init__(self, addresses=None, parent=None):
super(TableModel, self).__init__(parent)
self.table = [[1, 2, 3], [4, 5, 6]]
def rowCount(self, index=QModelIndex()):
return len(self.table)
def columnCount(self, index=QModelIndex()):
return len(self.table[0])
def data(self, index, role=Qt.DisplayRole):
if role == Qt.DisplayRole:
return self.table[index.row()] [index.column()]
else:
return None
def setData(self, index, value, role=Qt.EditRole):
self.table[index.row()] [index.column()] = value
return True
def flags(self, index):
return Qt.ItemIsEditable | Qt.ItemIsEnabled
def slotCurrentChanged(index1, index2):
print 'Index 1:', index1.row(), index1.column()
print 'Index 2:', index2.row(), index2.column()
print
def slotDisconnect():
view.selectionModel().currentChanged.disconnect(slotCurrentChanged)
app = QApplication(sys.argv)
model = TableModel()
view = QTableView()
view.setModel(model)
view.selectionModel().currentChanged.connect(slotCurrentChanged)
QTimer.singleShot(5000, slotDisconnect)
view.show()
sys.exit(app.exec_())
_______________________________________________
PySide mailing list
PySide@lists.pyside.org
http://lists.pyside.org/listinfo/pyside