title: dynamic qtreeview with custom delegates
body: <p>I'm using Qt 5.6 and my goal is to develop a dynamic tree using QTreeView that needs to populate items such as combo boxes, edit box, checkbox, buttons..etc depending on the settings loaded and the tree data can change as new data is loaded.  There will be many nodes to populate in the tree with parent and child nodes. </p>
  
  <p>I've read about different options to implement this type of treeview such as populating a QTreeView and implementing my own delegate by inheriting from QITemDelegate or QStyledItemDelegate or using Qt Quick's QML treeview.</p>
  
  <p>For my purposes I've chosen the first option to dynamically populate a tree and modify parameters but I'm having trouble setting the delegate i want for a selected cell only as the only options to set the delegate in the tree is to setItemDelegateForRow, setItemDelegateForColumn or setItemDelegate.  The tree will look something like the below.  How should i set a different delegate for each of the child nodes?</p>
  
  <pre><code>by (col, row)
  
  Parent(cell 0,0)
    -&gt;Child(cell 0,1) -combo box(1,1)
    -&gt;Child(cell 0,2) -button(1,2)
    -&gt;Child(cell 0,3) -check box(1,3)
   ...
   ...etc
  
  Parent(cell 0,10)
    -&gt;Child(cell 0,11) - edit box(1,11)
    -&gt;Child(cell 0,12) - edit box(1,12)
    -&gt;Child(cell 0,13) - check box(1,13)
   ...
   ...etc
  </code></pre>
  
  <p><strong>Edit</strong></p>
  
  <p>This is a simplified version of how I have setup my tree view so far. Found out the answer to why my child node column 1 was not showing was because i did not set the column count of the model.  I have updated the code below and it works now. </p>
  
  <pre><code>enum EditType
  {
      TYPE_Text,
      TYPE_CheckBox,
      TYPE_ComboBox,
      TYPE_Button
  };
  
  QTreeView* tree = new QTreeView(this);
  QStandardItemModel* model = new QStandardItemModel; 
  model-&gt;setColumnCount(2);
  tree-&gt;setModel(model);
  
  //set custom delegate for column 1 of the tree 
  CustomDelegate *customDelegate = new CustomDelegate(this);
  tree-&gt;setItemDelegateForColumn(1, customDelegate); 
  
  // Add parent nodes
  QStandardItem* parent1 = new QStandardItem(tr("parent1"));
  QStandardItem* parent2 = new QStandardItem(tr("parent2"));
  
  model-&gt;appendRow(parent1);
  model-&gt;appendRow(parent2);
  
  // add a child
  QList&lt;QStandardItem*&gt; childrow;
  QStandardItem* child = new QStandardItem(tr("child1"));
  childrow.append(child);
  QStandardItem* child_value = new QStandardItem();
  child_value-&gt;setData(TYPE_ComboBox, Qt::UserRole);
  childrow.append(child_value);
  parent1-&gt;appendRow(it_child);
  </code></pre>