[PyQt] connection to list view and combo pyqt
dboddie at trolltech.com
Wed Jan 23 18:16:52 GMT 2008
On Wed Jan 23 18:01:22 GMT 2008, Peter Liedler wrote:
> > You need to connect the selection model's signal to the titleSelected()
> > slot:
> > self.connect(self.listViewTitle.selectionModel(),
> > SIGNAL("selectionChanged(QItemSelection, QItemSelection)"),
> > self.titleSelected)
> Sorry, no sucess here. I don't get it.
One thing that was strange in your example was that you were subclassing
QAbstractListModel, but calling the __init__() method of the
Anyway, here's a simple, complete example that should work:
from PyQt4.QtCore import QObject, SIGNAL
from PyQt4.QtGui import *
def slot(selected, deselected):
print len(selected), "items selected"
print len(deselected), "items deselected"
if __name__ == "__main__":
app = QApplication(sys.argv)
model = QStandardItemModel()
for i in range(10):
model.appendRow([QStandardItem("Item %i" % i)])
listView = QListView()
Does that help in any way?
Lead Technical Writer, Trolltech ASA
More information about the PyQt