I'm trying to use a QTreeView as a view for a QComboBox.

I've done something like this:

Qt Code:
  1. TreeView m_view = new TreeView(this);
  2.  
  3. QComboBox* m_combo = new QComboBox(this);
  4. m_combo->setModel(m_view->getModel());
  5. m_combo->setView(m_view);
  6.  
  7. QStandardItem* item1 = new QStandardItem("One");
  8. QStandardItem* item2 = new QStandardItem("Two");
  9. QStandardItem* item3 = new QStandardItem("Three);
  10. QStandardItem* item4 = new QStandardItem("Four");
  11.  
  12. m_view->getModel()->appendRow(item1);
  13. item1->appendRow(item2);
  14. m_view->getModel()->appendRow(item3);
  15. m_view->getModel()->appendRow(item4);
To copy to clipboard, switch view to plain text mode 

My questions are:

1) Am I doing the right thing there?

2) How can I select an item from the list?

3) How can I know when an item has been selected?

For 2) and 3) I tried several things but failed

For example if the QTreeView is not set as a view for the combo box, I can use the signal clicked(), but this is not working with the view set on the combo box. If I use the combo's currentIndexChanged() signal, selecting item 2 will return index 0, because item 2 is a child of item 1 at index 0. I'm really confused about this model/view thing