title: QTreeView Display Directory
body: <p>I am currently trying to make a QTreeView to display the contents of the folder on the computer. However, I experienced some weird issue where . and .. are displayed in the tree view which I do not want that to happen. How am I suppose to disable showing . and .. in the tree view?</p>
  
  <p><a href="https://i.stack.imgur.com/yb98C.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yb98C.png" alt="enter image description here"></a></p>
  
  <p>Here is the code for the QTreeView.</p>
  
  <pre><code>model = new QDirModel(this);
  model-&gt;setReadOnly(true);
  model-&gt;setSorting(QDir::DirsFirst | QDir::IgnoreCase | QDir::Name);
  model-&gt;setFilter(QDir::Dirs);
  
  ui-&gt;treeView-&gt;setModel(model);
  
  // expand to D: Directory
  QModelIndex index = model-&gt;index("D:/");
  ui-&gt;treeView-&gt;expand(index);
  ui-&gt;treeView-&gt;scrollTo(index);
  ui-&gt;treeView-&gt;setCurrentIndex(index);
  ui-&gt;treeView-&gt;resizeColumnToContents(0);
  </code></pre>