PDA

View Full Version : Shortcut key for context menu



darshan.hardas
8th December 2008, 06:09
Hi,

I have a problem with context menu.....
I have a context menu of copy past action handler on QTableWidget.


QAction* copyAct = new QAction("&Copy", qTableWidgetObj);
copyAct->setShortcut(tr("Ctrl+C"));


and for paste:

QAction* pasteAct = new QAction("&Paste", qTableWidgetObj);
pasteAct->setShortcut(QKeySequence::Paste);


I connect this with a slot as


connect(copyAct, SIGNAL(triggered()), this, SLOT(slotCopy()));

I create context menu with


qTableWidgetObj->setContextMenuPolicy(Qt::ActionsContextMenu);

Contextmenu gets creates and works fine if I press on one of the options of context menu.
But when I press shortcut key on the table widget no slot is called.

Please let me know your suggestions as how to implement it?

jpn
28th December 2008, 20:32
Where do you call QWidget::addAction()?