title: QT5 Cannot get different custom context menus to work for different tables
body: <p>I am trying to get multiple (3) custom context menus to work, each for a different table view.</p>
  <p>My code works fine in debug but in release I am not getting the different context menus - the best I have managed to get is either the first menu working (and the others disabled) or displaced menus (i.e. the menu is offset relative to the top left corner of the screen not at the cursor).</p>
  <p>The code:</p>
  <pre><code>void DisplayWidget::Init()
  {
      // ParameterData Table
      pLabel_Param            = new QLabel(tr(&quot;PARAMETER DATABASE&quot;));
      pTableW_Param           = new QTableWidget(this);
         
      // EmuNameIn Table
      pLabel_EmuNameIn        = new QLabel(tr(&quot;EMULATOR NAME IN&quot;));
      pTableW_EmuNameIn       = new QTableWidget(this);
         
      // EmuNameOut Table
      pLabel_EmuNameOut       = new QLabel(tr(&quot;EMULATOR NAME OUT&quot;));
      pTableW_EmuNameOut      = new QTableWidget(this);
      
      // Setup context menus
      pTableW_Param-&gt;setContextMenuPolicy(Qt::CustomContextMenu);
      connect(pTableW_Param, SIGNAL(customContextMenuRequested(QPoint)), SLOT(customMenuRequested_Param(QPoint)));
      
      pTableW_EmuNameIn-&gt;setContextMenuPolicy(Qt::CustomContextMenu);
      connect(pTableW_EmuNameIn, SIGNAL(customContextMenuRequested(QPoint)), SLOT(customMenuRequested_EmuNameIn(QPoint)));
      
      pTableW_EmuNameOut-&gt;setContextMenuPolicy(Qt::CustomContextMenu);
      connect(pTableW_EmuNameOut, SIGNAL(customContextMenuRequested(QPoint)), SLOT(customMenuRequested_EmuNameOut(QPoint)));
  }
  
  
  void DisplayWidget::customMenuRequested_Param(QPoint pos) 
  {
      if(!pTableW_Param || (sizeOfTable_Param == 0)) return;
  
      QModelIndex index = pTableW_Param-&gt;indexAt(pos);
  
      QMenu *menuParam = new QMenu(this);
      if(IsEmuValid()) menuParam-&gt;addAction(pAct_AddParam);
      menuParam-&gt;addAction(pAct_SearchTable_Param);
      menuParam-&gt;popup(pTableW_Param-&gt;viewport()-&gt;mapToGlobal(pos));
  }
  
  void DisplayWidget::customMenuRequested_EmuNameIn(QPoint pos) 
  {
      if(!pTableW_EmuNameIn || !IsEmuValid() || (sizeOfTable_EmuNameIn == 0)) return;
  
      QModelIndex index = pTableW_EmuNameIn-&gt;indexAt(pos);
  
      QMenu *menuNameIn = new QMenu(this);
      menuNameIn-&gt;addAction(pAct_DeleteFromNameIn);
      menuNameIn-&gt;addAction(pAct_Toggle_InToOut);
      menuNameIn-&gt;addAction(pAct_SearchTable_EmuNameIn);
      menuNameIn-&gt;addAction(pAct_SortTable_EmuNameIn);
      menuNameIn-&gt;popup(pTableW_EmuNameIn-&gt;viewport()-&gt;mapToGlobal(pos));
  }
  
  void DisplayWidget::customMenuRequested_EmuNameOut(QPoint pos) 
  {
      if(!pTableW_EmuNameOut || !IsEmuValid() || (sizeOfTable_EmuNameOut == 0)) return;
  
      QModelIndex index = pTableW_EmuNameOut-&gt;indexAt(pos);
  
      QMenu *menuNameOut = new QMenu(this);
      menuNameOut-&gt;addAction(pAct_DeleteFromNameOut);
      menuNameOut-&gt;addAction(pAct_Toggle_OutToIn);
      menuNameOut-&gt;addAction(pAct_SearchTable_EmuNameOut);
      menuNameOut-&gt;addAction(pAct_SortTable_EmuNameOut);
      menuNameOut-&gt;popup(pTableW_EmuNameOut-&gt;viewport()-&gt;mapToGlobal(pos));
  }
  </code></pre>
  <p>I have tried looking / searching for the same problem, but failed to resolve the issue.</p>