[SOLVED]How to use shortcuts for QActions
-
I tried this, but it didn't work
@deleteAction = new QAction(tr("Delete "),ui->tableWidget);
connect(deleteAction, SIGNAL(triggered()),this,SLOT(on_actionDelete_triggered()));
deleteAction->setShortcut(Qt::Key_Delete);
deleteAction->setShortcutContext(Qt::WidgetShortcut);@ -
You've a bit mistaken with enums
"function proptotype":http://qt-project.org/doc/qt-4.8/qaction.html#shortcut-prop is:
@
void QAction::setShortcut(const QKeySequence &shortcut)
@one of "QKeySeqence ctors":http://qt-project.org/doc/qt-4.8/qkeysequence.html#QKeySequence-6 :
@
QKeySequence::QKeySequence (StandardKey key)
@where StandartKey: http://qt-project.org/doc/qt-4.8/qkeysequence.html#StandardKey-enum
so you should use:
@
deleteAction->setShortcut(QKeySequence::Delete);
@