Hell,<br><br>I am trying to build a selection tree, as below.  I hope to which files are checked. <br><br>O filename1<br>O filename2<br>O filename3<br>O filename4<br>......<br><br><br>I find the following codes fit my need well. But I do not know how to get the check state signal. I hope, <b>each time an item is checked or unchecked, I get a state change signal, and find the lists of checked items.</b><br>

Can someone help me out? Thanks. <br><br><a href="http://stackoverflow.com/questions/846684/a-listview-of-checkboxes-in-pyqt">http://stackoverflow.com/questions/846684/a-listview-of-checkboxes-in-pyqt</a><br><br><br><pre class="prettyprint">

<code><font size="4"><span class="kwd">from</span><span class="pln"> </span><span class="typ">PyQt4</span><span class="pun">.</span><span class="typ">QtCore</span><span class="pln"> </span><span class="kwd">import</span><span class="pln"> </span><span class="pun">*</span><span class="pln"><br>

</span><span class="kwd">from</span><span class="pln"> </span><span class="typ">PyQt4</span><span class="pun">.</span><span class="typ">QtGui</span><span class="pln"> </span><span class="kwd">import</span><span class="pln"> </span><span class="pun">*</span><span class="pln"><br>

</span><span class="kwd">import</span><span class="pln"> sys<br></span><span class="kwd">from</span><span class="pln"> random </span><span class="kwd">import</span><span class="pln"> randint<br><br><br>app </span><span class="pun">=</span><span class="pln"> </span><span class="typ">QApplication</span><span class="pun">(</span><span class="pln">sys</span><span class="pun">.</span><span class="pln">argv</span><span class="pun">)</span><span class="pln"><br>

<br>model </span><span class="pun">=</span><span class="pln"> </span><span class="typ">QStandardItemModel</span><span class="pun">()</span><span class="pln"><br><br></span><span class="kwd">for</span><span class="pln"> n </span><span class="kwd">in</span><span class="pln"> range</span><span class="pun">(</span><span class="lit">10</span><span class="pun">):</span><span class="pln">                   <br>

    item </span><span class="pun">=</span><span class="pln"> </span><span class="typ">QStandardItem</span><span class="pun">(</span><span class="str">&#39;Item %s&#39;</span><span class="pln"> </span><span class="pun">%</span><span class="pln"> randint</span><span class="pun">(</span><span class="lit">1</span><span class="pun">,</span><span class="pln"> </span><span class="lit">100</span><span class="pun">))</span><span class="pln"><br>

    check </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Qt</span><span class="pun">.</span><span class="typ">Checked</span><span class="pln"> </span><span class="kwd">if</span><span class="pln"> randint</span><span class="pun">(</span><span class="lit">0</span><span class="pun">,</span><span class="pln"> </span><span class="lit">1</span><span class="pun">)</span><span class="pln"> </span><span class="pun">==</span><span class="pln"> </span><span class="lit">1</span><span class="pln"> </span><span class="kwd">else</span><span class="pln"> </span><span class="typ">Qt</span><span class="pun">.</span><span class="typ">Unchecked</span><span class="pln"><br>

    item</span><span class="pun">.</span><span class="pln">setCheckState</span><span class="pun">(</span><span class="pln">check</span><span class="pun">)</span><span class="pln"><br>    item</span><span class="pun">.</span><span class="pln">setCheckable</span><span class="pun">(</span><span class="kwd">True</span><span class="pun">)</span><span class="pln"><br>

    model</span><span class="pun">.</span><span class="pln">appendRow</span><span class="pun">(</span><span class="pln">item</span><span class="pun">)</span><span class="pln"><br><br><br>view </span><span class="pun">=</span><span class="pln"> </span><span class="typ">QListView</span><span class="pun">()</span><span class="pln"><br>

view</span><span class="pun">.</span><span class="pln">setModel</span><span class="pun">(</span><span class="pln">model</span><span class="pun">)</span><span class="pln"><br><br>view</span><span class="pun">.</span><span class="pln">show</span><span class="pun">()</span><span class="pln"><br>

app</span><span class="pun">.</span><span class="pln">exec_</span></font><span class="pun"><font size="4">()</font><br><br><br></span><span class="pln"></span></code></pre><br clear="all">---------------------------<br>He Jibo<br>

Department of Psychology,<br>Beckman Institute for Advanced Science and Technology<br>University of Illinois, Urbana Champaign,<br>603 East Daniel St.,<br>Champaign, IL 61820<br>website: <a href="http://www.hejibo.info">www.hejibo.info</a><br>

<br>