title: Qt: set columns in treeView
body: <p>How can I implement this code I have for a qTreeWidget for a qTreeView?</p>
  
  <pre><code>for (const auto &amp; i : names) {
      QTreeWidgetItem * item = new QTreeWidgetItem(ui-&gt;treeWidget);
      item-&gt;setText(0, QString::fromStdString(i));
      ui-&gt;treeWidget-&gt;addTopLevelItem(item);
      const std::unordered_map&lt;std::string, double&gt; map = m_reader.getMapFromEntry(i);
      for (const auto &amp; j : map) {
          QTreeWidgetItem * item2 = new QTreeWidgetItem();
          item2-&gt;setText(0,QString::fromStdString(j.first));
          item2-&gt;setText(1,QString::number(j.second));
          item-&gt;addChild(item2);
      }
  
  }
  </code></pre>
  
  <p>I have a model and a treeView, like this:  </p>
  
  <pre><code>m_model = new QStandardItemModel(m_reader.getAllNames().size(),2,this);
  ui-&gt;treeView-&gt;setModel(m_model);
  </code></pre>
  
  <p>I tried this, but that only shows one column:</p>
  
  <pre><code>QStandardItem * parentItem = m_model-&gt;invisibleRootItem();
  for (const auto &amp; i : names) {
      QStandardItem * item = new QStandardItem(QString::fromStdString(i));
      parentItem-&gt;appendRow(item);
      const std::unordered_map&lt;std::string, double&gt; map = m_reader.getMapFromEntry(i);
      for (const auto &amp; j : map) {
          QList&lt;QStandardItem *&gt; rowItems;
          rowItems &lt;&lt; new QStandardItem(QString::fromStdString(j.first));
          rowItems &lt;&lt; new QStandardItem(QString::number(j.second));
          item-&gt;appendRow(rowItems);
      }
  }
  </code></pre>
  
  <p>With the treeWidget, I had so set the columnCount, like this:</p>
  
  <pre><code>ui-&gt;treeWidget-&gt;setColumnCount(2);
  </code></pre>
  
  <p>But treeView does not have a method like this.</p>
  
  <p>So, to summarize: <strong>How can I implement a TreeView with more than one column?</strong></p>
  
  <p><strong>EDIT:</strong><br>
  To clarify, I want something like this:  </p>
  
  <p>|-A<br>
  | |-B-C<br>
  | |-D-E  </p>
  
  <p>where A is the parent and B,C,D,E the children, with B,D being in column 0 and C,E in column 1.</p>
  
  <p>Hope this helps!</p>