Qt: Recognizing items of QTreeView
<p>Example Tree View:</p>

<pre><code>1. a
1.1. b
1.1.1. c
</code></pre>

<p>I want to know how I can make my code recognize I right clicked whether a or b or c. I am able to create a TreeView, add a b c to it, and get the item at the position of the right click but I don't know how I can recognize the item so right clicks would create different context menus respecting the item clicked. I use standard item model (<code>QStandardItemModel</code>) and so far what I got is:</p>

<pre><code>void MyWindow::make_tree_custom_menu(const QPoint&amp; pos){
    QModelIndex index = treeView-&gt;indexAt(pos);
    int itemRow = index.row();
    int itemCol = index.column();
    QStandardItem* itemAtPos = model-&gt;item(itemRow, itemCol);
    itemAtPos-&gt;setText("meh");
}
</code></pre>

<p>I know that with <code>QTreeWidgetItem</code>s you can do <code>QTreeWidgetItem* newitem = new QTreeWidgetItem(name, itemtype);</code> but as far as I could see in the docs, <code>QStandardItem</code> doesn't have such constructor. Also, I know that <a href="https://stackoverflow.com/questions/15196207/how-to-find-an-item-in-a-qtreeview">this</a> exists, but it is unanswered. Therefore, I would like any help on possible methods to identify tree view items in such an application.</p>