title: Qt context menu breaking selection in QTreeView
body: <p>I have a <code>QTreeView</code> class with a context menu installed as follows:</p>
  
  <pre><code>m_ui.tree-&gt;setContextMenuPolicy(Qt::CustomContextMenu);
  connect(m_ui.tree, SIGNAL(customContextMenuRequested(const QPoint&amp;)),
          this, SLOT(ShowTreeContextMenu(const QPoint&amp;)));
  ...
  void ShowTreeContextMenu(const QPoint&amp; point)
  {
     m_treeContextMenu-&gt;exec(m_ui.tree-&gt;viewport()-&gt;mapToGlobal(point));
  }
  </code></pre>
  
  <p>However when the context menu is being displayed the <code>QTreeView</code> will no longer respond to mouse clicks. Clicking on an item in the <code>QTreeView</code> while the context menu is displayed will remove the context menu but does not select the clicked item.</p>
  
  <p>This is especially disorientating when right clicking on a new item, as the context menu pops up over the new item, but as the item was not selected the contents of the context menu are referring to the previously selected item.</p>