Hello all,<br>        Greetings.. After a spending a long time for googling i found the way to list the contents of a particular directory. Thanks to QDirModel.<br><br>       My aim here is to allow the user to exclude specific directories within the chosen directory.. After adding a particular directory to the exclusion list(on the right side)<span>the selected directory and it&#39;s </span><span>descendents should be removed(or hidden)from the tree view so that the user is not allowed to select the same folder again.. <br>
<br>      Given here the minimal example needed for my app.. In this example when the user presses add to exclude list push button the folder is added to the exclude folders listwidget..<br><br>from PyQt4 import QtCore, QtGui<br>
<br>class Ui_Dialog(QtGui.QDialog):<br>    <br>    def __init__(self,parent=None):<br>        QtGui.QDialog.__init__(self,parent)<br>        self.resize(600, 500)<br><br>        self.model = QtGui.QDirModel()<br>        self.tree = QtGui.QTreeView(self)<br>
        self.tree.setModel(self.model)<br>        self.model.setFilter(QtCore.QDir.Dirs|QtCore.QDir.NoDotAndDotDot)<br>        self.tree.setSortingEnabled(True)<br>        self.tree.setRootIndex(self.model.index(&quot;/home/jebagnanadasa/Python-3.1.1&quot;))<br>
        <br>        self.tree.hideColumn(1)<br>        self.tree.setWindowTitle(&quot;Dir View&quot;)<br>        self.tree.resize(400, 480)<br>        self.tree.setColumnWidth(0,150)<br>        self.tree.show()<br><br>        self.pushButton = QtGui.QPushButton(self)<br>
        self.pushButton.setGeometry(QtCore.QRect(420, 30, 151, 28))<br>        self.listWidget = QtGui.QListWidget(self)<br>        self.listWidget.setGeometry(QtCore.QRect(410, 80, 171, 231))<br><br>        QtCore.QObject.connect(self.tree, QtCore.SIGNAL(&quot;clicked(QModelIndex)&quot;), self.test)<br>
        QtCore.QObject.connect(self.pushButton,QtCore.SIGNAL(&#39;clicked()&#39;),self.addToList)<br>        QtCore.QMetaObject.connectSlotsByName(self)<br>        <br>        self.setWindowTitle(QtGui.QApplication.translate(&quot;Dialog&quot;, &quot;Dialog&quot;, None, QtGui.QApplication.UnicodeUTF8))<br>
        self.pushButton.setText(QtGui.QApplication.translate(&quot;Dialog&quot;, &quot;Add to Exclude List&quot;, None, QtGui.QApplication.UnicodeUTF8))<br><br>    def test(self,index):<br>        <br>        if self.model.data(index.parent())==&quot;jebagnanadasa&quot;:<br>
            self.selectedDirectoryPath=self.model.data(index)<br>            print(self.selectedDirectoryPath)<br>        else:<br>            dirHierarchy=[]<br>            dirHierarchy.insert(0,self.model.data(index))<br>
            while (self.model.data(index.parent())!=&quot;jebagnanadasa&quot;):<br>                index=index.parent()<br>                dirHierarchy.insert(0,self.model.data(index))<br>            self.selectedDirectoryPath=&quot;/&quot;.join(dirHierarchy)<br>
            print(self.selectedDirectoryPath)<br><br>        #self.model.removeRow(0,index)<br><br>    def addToList(self):<br>        self.listWidget.addItem(self.selectedDirectoryPath)<br><br><br>if __name__ == &quot;__main__&quot;:<br>
    import sys<br>    app = QtGui.QApplication(sys.argv)<br>    ui = Ui_Dialog()<br>    ui.show()<br>    sys.exit(app.exec_())<br><br>See the screenshot also..<br><br><img title="?ui=2&amp;view=att&amp;th=12637fd44b798078&amp;attid=0.1&amp;disp=attd&amp;realattid=ii_12637fd44b798078&amp;zw" alt="?ui=2&amp;view=att&amp;th=12637fd44b798078&amp;attid=0.1&amp;disp=attd&amp;realattid=ii_12637fd44b798078&amp;zw" src="cid:ii_12637fd44b798078"><br>

<br>Is there a way that i can make the excluded directories to be ignored when displaying the contents of the directory on consecutive startup(since it was already on the exclusion list)?<br><br>Any help would be much appreciated.. Thanks..<br>
<br>P.S: remove() and rmdir() is not recommended since it deletes the directories entirely from the file System!<br></span>