Hai all,<br><br>        I&#39;ve populated the directory tree using QDirModel. My aim is whenever i click on the patriculr folder or directory, the directory and it&#39;s children should be deleted from the model.. I don&#39;t know what am i doing wrong in the code below.. <br>
<pre class="prettyprint"><code><span class="kwd">from</span><span class="pln"> </span><span class="typ">PyQt4</span><span class="pln"> </span><span class="kwd">import</span><span class="pln"> </span><span class="typ">QtCore</span><span class="pun">,</span><span class="pln"> </span><span class="typ">QtGui</span><span class="pln"><br>
<br></span><span class="kwd">class</span><span class="pln"> </span><span class="typ">Ui_Dialog</span><span class="pun">(</span><span class="typ">QtGui</span><span class="pun">.</span><span class="typ">QDialog</span><span class="pun">):</span><span class="pln"><br>
<br>    </span><span class="kwd">def</span><span class="pln"> __init__</span><span class="pun">(</span><span class="kwd">self</span><span class="pun">,</span><span class="pln">parent</span><span class="pun">=</span><span class="kwd">None</span><span class="pun">):</span><span class="pln"><br>
        </span><span class="typ">QtGui</span><span class="pun">.</span><span class="typ">QDialog</span><span class="pun">.</span><span class="pln">__init__</span><span class="pun">(</span><span class="kwd">self</span><span class="pun">,</span><span class="pln">parent</span><span class="pun">)</span><span class="pln"><br>
        </span><span class="kwd">self</span><span class="pun">.</span><span class="pln">setObjectName</span><span class="pun">(</span><span class="str">&quot;Dialog&quot;</span><span class="pun">)</span><span class="pln"><br>
        </span><span class="kwd">self</span><span class="pun">.</span><span class="pln">resize</span><span class="pun">(</span><span class="lit">600</span><span class="pun">,</span><span class="pln"> </span><span class="lit">500</span><span class="pun">)</span><span class="pln"><br>
<br><br>        </span><span class="kwd">self</span><span class="pun">.</span><span class="pln">model </span><span class="pun">=</span><span class="pln"> </span><span class="typ">QtGui</span><span class="pun">.</span><span class="typ">QDirModel</span><span class="pun">()</span><span class="pln"><br>
        </span><span class="kwd">self</span><span class="pun">.</span><span class="pln">tree </span><span class="pun">=</span><span class="pln"> </span><span class="typ">QtGui</span><span class="pun">.</span><span class="typ">QTreeView</span><span class="pun">()</span><span class="pln"><br>
        </span><span class="kwd">self</span><span class="pun">.</span><span class="pln">tree</span><span class="pun">.</span><span class="pln">setModel</span><span class="pun">(</span><span class="kwd">self</span><span class="pun">.</span><span class="pln">model</span><span class="pun">)</span><span class="pln"><br>
        </span><span class="kwd">print</span><span class="pun">(</span><span class="kwd">self</span><span class="pun">.</span><span class="pln">model</span><span class="pun">.</span><span class="pln">flags</span><span class="pun">(</span><span class="kwd">self</span><span class="pun">.</span><span class="pln">model</span><span class="pun">.</span><span class="pln">index</span><span class="pun">(</span><span class="str">&quot;c:\Program Files&quot;</span><span class="pun">)))</span><span class="pln"><br>
        </span><span class="kwd">self</span><span class="pun">.</span><span class="pln">model</span><span class="pun">.</span><span class="pln">setFilter</span><span class="pun">(</span><span class="typ">QtCore</span><span class="pun">.</span><span class="typ">QDir</span><span class="pun">.</span><span class="typ">Dirs</span><span class="pun">|</span><span class="typ">QtCore</span><span class="pun">.</span><span class="typ">QDir</span><span class="pun">.</span><span class="typ">NoDotAndDotDot</span><span class="pun">)</span><span class="pln"><br>
<br><br>        </span><span class="kwd">self</span><span class="pun">.</span><span class="pln">tree</span><span class="pun">.</span><span class="pln">setSortingEnabled</span><span class="pun">(</span><span class="kwd">True</span><span class="pun">)</span><span class="pln"><br>
<br>        </span><span class="kwd">self</span><span class="pun">.</span><span class="pln">tree</span><span class="pun">.</span><span class="pln">setRootIndex</span><span class="pun">(</span><span class="kwd">self</span><span class="pun">.</span><span class="pln">model</span><span class="pun">.</span><span class="pln">index</span><span class="pun">(</span><span class="str">&quot;c:\Program Files&quot;</span><span class="pun">))</span><span class="pln"><br>
<br>        </span><span class="com">#self.tree.hideColumn(1)</span><span class="pln"><br>        </span><span class="com">#self.tree.hideColumn(2)</span><span class="pln"><br>        </span><span class="com">#self.tree.hideColumn(3)</span><span class="pln"><br>
        </span><span class="kwd">self</span><span class="pun">.</span><span class="pln">tree</span><span class="pun">.</span><span class="pln">setWindowTitle</span><span class="pun">(</span><span class="str">&quot;Dir View&quot;</span><span class="pun">)</span><span class="pln"><br>
        </span><span class="kwd">self</span><span class="pun">.</span><span class="pln">tree</span><span class="pun">.</span><span class="pln">resize</span><span class="pun">(</span><span class="lit">400</span><span class="pun">,</span><span class="pln"> </span><span class="lit">480</span><span class="pun">)</span><span class="pln"><br>
        </span><span class="kwd">self</span><span class="pun">.</span><span class="pln">tree</span><span class="pun">.</span><span class="pln">setColumnWidth</span><span class="pun">(</span><span class="lit">0</span><span class="pun">,</span><span class="lit">200</span><span class="pun">)</span><span class="pln"><br>
<br>        </span><span class="kwd">self</span><span class="pun">.</span><span class="pln">tree</span><span class="pun">.</span><span class="pln">show</span><span class="pun">()</span><span class="pln"><br>        </span><span class="typ">QtCore</span><span class="pun">.</span><span class="typ">QObject</span><span class="pun">.</span><span class="pln">connect</span><span class="pun">(</span><span class="kwd">self</span><span class="pun">.</span><span class="pln">tree</span><span class="pun">,</span><span class="pln"> </span><span class="typ">QtCore</span><span class="pun">.</span><span class="pln">SIGNAL</span><span class="pun">(</span><span class="str">&quot;clicked(QModelIndex)&quot;</span><span class="pun">),</span><span class="pln"> </span><span class="kwd">self</span><span class="pun">.</span><span class="pln">test</span><span class="pun">)</span><span class="pln"><br>
        </span><span class="typ">QtCore</span><span class="pun">.</span><span class="typ">QMetaObject</span><span class="pun">.</span><span class="pln">connectSlotsByName</span><span class="pun">(</span><span class="kwd">self</span><span class="pun">)</span><span class="pln"><br>
<br>        </span><span class="kwd">self</span><span class="pun">.</span><span class="pln">setWindowTitle</span><span class="pun">(</span><span class="typ">QtGui</span><span class="pun">.</span><span class="typ">QApplication</span><span class="pun">.</span><span class="pln">translate</span><span class="pun">(</span><span class="str">&quot;Dialog&quot;</span><span class="pun">,</span><span class="pln"> </span><span class="str">&quot;Dialog&quot;</span><span class="pun">,</span><span class="pln"> </span><span class="kwd">None</span><span class="pun">,</span><span class="pln"> </span><span class="typ">QtGui</span><span class="pun">.</span><span class="typ">QApplication</span><span class="pun">.</span><span class="typ">UnicodeUTF8</span><span class="pun">))</span><span class="pln"><br>
<br>    </span><span class="kwd">def</span><span class="pln"> test</span><span class="pun">(</span><span class="kwd">self</span><span class="pun">,</span><span class="pln">index</span><span class="pun">):</span><span class="pln"><br>
<br><br>        </span><span class="kwd">print</span><span class="pun">(</span><span class="kwd">self</span><span class="pun">.</span><span class="pln">model</span><span class="pun">.</span><span class="pln">filePath</span><span class="pun">(</span><span class="pln">index</span><span class="pun">))</span><span class="pln"><br>
<br>        </span><span class="kwd">print</span><span class="pun">(</span><span class="kwd">self</span><span class="pun">.</span><span class="pln">model</span><span class="pun">.</span><span class="pln">rowCount</span><span class="pun">(</span><span class="pln">index</span><span class="pun">))</span><span class="pln"><br>
<br>         </span><span class="com">#self.model.beginRemoveRows(index.parent(),index.row(),self.model.rowCount(index))</span><span class="pln"><br>        </span><span class="com">#self.model.endRemoveRows()</span><span class="pln"><br>
<br>        </span><span class="kwd">print</span><span class="pun">(</span><span class="str">&quot;Row of the index =&quot;</span><span class="pun">,</span><span class="pln">index</span><span class="pun">.</span><span class="pln">row</span><span class="pun">())</span><span class="pln"><br>
<br><br>        </span><span class="kwd">print</span><span class="pun">(</span><span class="str">&quot;Parent = &quot;</span><span class="pun">,</span><span class="kwd">self</span><span class="pun">.</span><span class="pln">model</span><span class="pun">.</span><span class="pln">data</span><span class="pun">(</span><span class="pln">index</span><span class="pun">.</span><span class="pln">parent</span><span class="pun">()))</span><span class="pln"><br>
<br></span><span class="kwd">if</span><span class="pln"> __name__ </span><span class="pun">==</span><span class="pln"> </span><span class="str">&quot;__main__&quot;</span><span class="pun">:</span><span class="pln"><br>    </span><span class="kwd">import</span><span class="pln"> sys<br>
    app </span><span class="pun">=</span><span class="pln"> </span><span class="typ">QtGui</span><span class="pun">.</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>
    ui </span><span class="pun">=</span><span class="pln"> </span><span class="typ">Ui_Dialog</span><span class="pun">()</span><span class="pln"><br>    </span><span class="com">#ui.show()</span><span class="pln"><br>    sys</span><span class="pun">.</span><span class="kwd">exit</span><span class="pun">(</span><span class="pln">app</span><span class="pun">.</span><span class="pln">exec_</span><span class="pun">())</span><span class="pln"><br>
</span></code></pre>Any experts.. Please correct me as early as possible.. Thank you all..<br><br><br><br>