Hello. I am trying to make a right click context menu appear over an item inside a QTableWidget.
I tried several things, but somehow it is not working or, not working properly.
Qt Code:
  1. void fileHandler::ctxMenu(const QPoint &pos)//started
  2. {
  3. QMenu *menu = new QMenu;
  4. menu->addAction(tr("Test Item"), this, SLOT(test_slot()));
  5. menu->addSeparator();
  6. menu->addAction(tr("Test Item"), this, SLOT(test_slot()));
  7. menu->exec(m_ui->tableWidget->mapToGlobal(pos));
  8. }
To copy to clipboard, switch view to plain text mode 
In the constructor i am doing this:
Qt Code:
  1. connect(m_ui->tableWidget, SIGNAL(customContextMenuRequested(const QPoint &)), this, SLOT(ctxMenu(const QPoint &)));
To copy to clipboard, switch view to plain text mode 
The problem with this thing is that when i right click on an item the popup menu appears not next to the x,y coordinates of where i clicked but somewhat x+50 px or so(only for the example i have). i also want to have a context menu only on items. I couldn't find anything to work like i want.
I want to add operations with fast navigation using the context menu for selected item or items. Thank you.