title: Adding a right-click menu for specific items in QTreeView
body: <p>I'm writing a Qt desktop application in c++ with Qt Creator.</p>
  
  <p>I declared in my main window a treeView, and a compatible model.</p>
  
  <p>Now, I would like to have a right-click menu for the tree item. Not for all of the items, but for a part of them, for example: for the tree elements with an even index.</p>
  
  <p>I tried adding a simple context menu with the following code:</p>
  
  <p><strong>in the .h file:</strong></p>
  
  <pre><code>QStandardItemModel* model;
  QMenu* contextMenu;
  QAction* uninstallAction;
  private slots:
      void uninstallAppletClickedSlot();
  </code></pre>
  
  <p><strong>and in the .cpp file:</strong></p>
  
  <p>in the constructor:</p>
  
  <pre><code>ui-&gt;treeView-&gt;setModel(model);
  contextMenu = new QMenu(ui-&gt;treeView);
  ui-&gt;treeView-&gt;setContextMenuPolicy(Qt::ActionsContextMenu);
  uninstallAction = new QAction("Uninstall TA",contextMenu);
  ui-&gt;treeView-&gt;addAction(uninstallAction);
  connect(uninstallAction, SIGNAL(triggered()), this, SLOT(uninstallAppletClickedSlot()));
  </code></pre>
  
  <p><strong>and a slot:</strong></p>
  
  <pre><code>void MainWindow::uninstallAppletClickedSlot()
  {
  
  }
  </code></pre>
  
  <p>this code gives me a context menu with the wanted action, but do you have any idea how can I add this action only for the <code>QStandardItem</code>s with the even indexes??</p>
  
  <p><strong>BTW, I'm adding items to the treeView by the following way:</strong></p>
  
  <pre><code>void MainWindow::AddItem(QString name)
  {
  QStandardItem *parentItem = model-&gt;invisibleRootItem();
  QStandardItem *app = new QStandardItem(name);
  parentItem-&gt;appendRow(app);
  }
  </code></pre>
  
  <p>I googled a lot, but found nothing :(</p>
  
  <p>thanks in advance!</p>