Qt key Press ShortCuts Error.
Pada_ last edited by
Qt5.4 Linux 64 Bit is in use.
I am setting a model in TableView and I want to delete a cell row or column by selecting one cell and pressing Ctrl + Delete + C on the keyboard.
Is there a way to set it in ShoutCut?
Modeifier is set to Ctrl + shift. It is also problematic to search condition after setting Qt :: Key_Delete and Qt :: Key_C in general.
SamurayH last edited by
QAction is what you're looking for. It's very easy to use... so for your shortcut try this:
QAction *rowCellDelAct = new QAction(this); rowCellDelAct->setShortcut(QKeySequence(Qt::CTRL+Qt::Key_Delete, Qt::CTRL+Qt::Key_C)); connect(rowCellDelAct, &QAction::triggered, &MainWindow::deleteRowCell); TableView->addAction(rowCellDelAct);
Note: The action must be added to the widget that is going to have focus when the user is allowed to trigger that action. In your case, it is the TableView.