title: Multi-level QTreeView
body: <p>I'm having a hard time understanding how to set a multilevel QTree using the QTreeView and QStandardItemModel.</p>
  
  <p>Here's what I have:</p>
  
  <pre><code>from PySide.QtGui import *
  import sys
  
  class MainFrame(QWidget):
      def __init__(self):
          QWidget.__init__(self)
  
          tree = {'root': {
                      "1": ["A", "B", "C"],
                      "2": {
                          "2-1": ["G", "H", "I"],
                          "2-2": ["J", "K", "L"]},
                      "3": ["D", "E", "F"]}
          }
  
          self.tree = QTreeView(self)
          root_model = QStandardItemModel()
          self.tree.setModel(root_model)
  
          for r,root in enumerate(sorted(tree)):
              root_item = QStandardItem(root)
              root_model.setItem(r,root_item)
  
              for c,child in enumerate(sorted(tree[root])):
                  child_model = QStandardItemModel(root_model)
                  child_item = QStandardItem(child)
                  child_model.setItem(c, child_item)
  
                  for gc, grand_child in enumerate(sorted(tree[root][child])):
                      grand_child_model = QStandardItemModel(child_model)
                      grand_child_item = QStandardItem(grand_child)
                      grand_child_model.setItem(gc,grand_child_item)
  
                      if type(tree[root][child]) == dict:
                          for ggc, gran_grand_child in enumerate(sorted(tree[root][child][grand_child])):
                              gran_grand_child_model = QStandardItemModel(grand_child_model)
                              gran_grand_child_item = QStandardItem(gran_grand_child)
                              gran_grand_child_model.setItem(ggc, gran_grand_child_item)
  
  if __name__ == "__main__":
      app = QApplication(sys.argv)
      main = MainFrame()
      main.show()
      sys.exit(app.exec_())
  </code></pre>
  
  <p>I want it to look like this:</p>
  
  <p><img src="https://i.stack.imgur.com/ZDYo6.png" alt="tree"></p>
  
  <p>So far only the 'root' item is showing, it's not throwing any error. </p>
  
  <p>Also, I made this for-loops in a bit of hurry, it's kind hard to read/understand because it has too many nested for loops. I wonder if there's a better way to expand the tree based on the initial dict.</p>