title: How to select item in QComboBox with QTreeView
body: <p>I was trying to select item "leaf2" from QComboBox with QTreeView in the below code.</p>
  
  <p>I just want to select items with no child from text by code. (if there is a child, it won't be selectable)</p>
  
  <p>How can I select item or index with no child item?</p>
  
  <p>Can anyone help me with this problem?</p>
  
  <p>Thank you.</p>
  
  <pre><code>void Main::initView()
  {
      QStandardItemModel *model = new QStandardItemModel;
      QStandardItem *root_item = model-&gt;invisibleRootItem();
  
      // Build Model Items
      QStandardItem *node_item = NULL;
      node_item = new QStandardItem("Node");
      node_item-&gt;setFlags(Qt::ItemIsEnabled);
      root_item-&gt;appendRow(node_item);
  
      QStandardItem *leaf_item = new QStandardItem("leaf1");
      leaf_item -&gt;setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
      node_item-&gt;appendRow(leaf_item );
  
      leaf_item = new QStandardItem("leaf2");
      leaf_item -&gt;setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
      node_item-&gt;appendRow(leaf_item );
  
      // Set Model to TreeViewComboBox
      ui.cb_treevew-&gt;setModel(model);
  
      ui.cb_treeview-&gt;setCurrentIndex(0); // "Node" is selected.
      ui.cb_treeview-&gt;setCurrentIndex(1); // Nothing is selected.
      ui.cb_treeview-&gt;setCurrentIndex(2); // Nothing is selected.
      ui.cb_treeview-&gt;setCurrentIndex(3); // Nothing is selected.
  }
  </code></pre>
  
  <p>Here is my code for CTreeViewComboBox.</p>
  
  <pre><code>CTreeViewComboBox::CTreeViewComboBox(QWidget *parent) : QComboBox(parent)
  {
      QTreeView* treeView = new QTreeView(this);
      treeView-&gt;setEditTriggers(QTreeView::NoEditTriggers);
      treeView-&gt;setSelectionBehavior(QTreeView::SelectRows);
      treeView-&gt;setSelectionMode(QTreeView::SingleSelection);
      treeView-&gt;setItemsExpandable(true);
      treeView-&gt;header()-&gt;setVisible(false);
      treeView-&gt;setWordWrap(true);
      setView(treeView);
  }
  </code></pre>
  
  <p>PS: I tried to select items as following, but not working. :(</p>
  
  <pre><code>ui.cb_treeview-&gt;treeView()-&gt;setCurrentIndex(getModelIndexFromText("leaf2"));
  </code></pre>