Hello,<div><br></div><div>I'm trying to understand the model/view programming while making a kind of tag-based browser. I have some absoluteFilePath in a database associated to one ore more tags (which are strings) . I'm trying to display those files (or directories of course) in a view. Hence, I created a subclass of QFileSystemModel but I'm a little bit lost...</div>

<div><br></div><div>I overredided the data() method which, if I have understood, is used to give the data to display to the view. I have done things like : </div><div><br></div><div><div><font class="Apple-style-span" face="'courier new', monospace">def data(self, modelIndex, role=Qt.DisplayRole):</font></div>

<div><font class="Apple-style-span" face="'courier new', monospace">        if not modelIndex.isValid():</font></div><div><font class="Apple-style-span" face="'courier new', monospace">            return QVariant()</font></div>

<div><font class="Apple-style-span" face="'courier new', monospace">        if modelIndex.row() >= len(self.files_list):</font></div><div><font class="Apple-style-span" face="'courier new', monospace">            return QVariant()</font></div>

<div><font class="Apple-style-span" face="'courier new', monospace">        return self.files_list[modelIndex.row()]</font></div></div><div><br></div><div>where files_list is a list of QFileInfo. I've also tried to return only the name of the file but it is not working. In clear, I'd like to do something like:</div>

<div><br></div><div><font class="Apple-style-span" face="'courier new', monospace">files_list = ['file1', 'file2', 'dir1'] # Of course, those files aren't systematically in the same directory</font></div>

<div><font class="Apple-style-span" face="'courier new', monospace">model = MyFileSystemModel(files_list)</font></div><div><font class="Apple-style-span" face="'courier new', monospace">view.setModel(model)</font></div>

<div><br></div><div>I'm quite sure I didn't understand exactly how it works. Indeed, how the view could display the right icon (a dir-icon or a file-icon). </div><div><br></div><div>Could someone explains me how should I do ? I'm not asking code, I only want to understand how model/programming works and how should I do to display a specific list of files. I read the documentation about model/view programming but it still obscure for me.</div>

<div><br></div><div>Thank you by advance,</div><div>Gaëtan</div>