i am adding QAction to QTableWidget as
m_pCutAction = new QAction( "Cut",this );
m_pCutAction->setIcon(QIcon(":/Img/cut.png"));
m_pCutAction->setShortcut(Qt::CTRL + Qt::Key_X);
connect(m_pCutAction, SIGNAL(triggered()), this, SLOT(cut()));
m_pCopyAction = new QAction( "Copy",this );
m_pCopyAction->setIcon(QIcon(":/Img/copy.png"));
m_pCopyAction->setShortcut(Qt::CTRL + Qt::Key_C);
and in contextMenu
void contextMenuEvent(QContextMenuEvent *event)
{
QScopedPointer<QMenu>menu(new QMenu());
menu->addAction(m_pCutAction);
menu->addAction(m_pCopyAction);
menu->addAction(m_pPasteAction);
menu->exec(event->globalPos());
QTableWidget::contextMenuEvent(event);
}
but the action is not executing for Ctrl + X but it is executing from Ctrl +C. Copy operation i can perform but Cut operation i cant perform using keys.
i tried
m_pCutAction ->setShortcut(QKeySequence::Cut);
but this is also not helping me. same for paste and delete. only Copy operation i can do.