[PyQt] QStandardItem check state

He Jibo hejibo at gmail.com
Fri Jun 11 18:59:36 BST 2010


Hell,

I am trying to build a selection tree, as below.  I hope to which files are
checked.

O filename1
O filename2
O filename3
O filename4
......


I find the following codes fit my need well. But I do not know how to get
the check state signal. I hope, *each time an item is checked or unchecked,
I get a state change signal, and find the lists of checked items.*
Can someone help me out? Thanks.

http://stackoverflow.com/questions/846684/a-listview-of-checkboxes-in-pyqt


from PyQt4.QtCore import *
from PyQt4.QtGui import *
import sys
from random import randint


app = QApplication(sys.argv)

model = QStandardItemModel()

for n in range(10):

    item = QStandardItem('Item %s' % randint(1, 100))

    check = Qt.Checked if randint(0, 1) == 1 else Qt.Unchecked

    item.setCheckState(check)
    item.setCheckable(True)

    model.appendRow(item)


view = QListView()

view.setModel(model)

view.show()

app.exec_()



---------------------------
He Jibo
Department of Psychology,
Beckman Institute for Advanced Science and Technology
University of Illinois, Urbana Champaign,
603 East Daniel St.,
Champaign, IL 61820
website: www.hejibo.info
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20100611/51480abd/attachment.html>


More information about the PyQt mailing list