Hi, everyone!
I wanna ask the solution for the situation:

My project has MainWindow Class and tableView and textEdit
(last two were created through the Designer in mainwindow.ui).

I need to do some action when shortcut pressed in tableView.
I've got right reaction through the
Qt Code:
  1. bool MainWindow::eventFilter(QObject *watched, QEvent *event)
To copy to clipboard, switch view to plain text mode 
here is the code:
Qt Code:
  1. ...
  2. // in MainWindow constructor
  3. ui->tableView->installEventFilter(this);
  4. ...
  5.  
  6. bool MainWindow::eventFilter(QObject *watched, QEvent *event)
  7. {
  8. if(watched == ui->tableView && event->type() == QEvent::KeyPress){
  9. QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
  10. qDebug()<<keyEvent->key();// DO SOMETHING
  11. }
  12. return QWidget::eventFilter(watched, event);
  13. }
To copy to clipboard, switch view to plain text mode 

But maybe there is a simpler solution? How to catch keypress in tableView?

Cause i've created tableView in *.ui i can't simple use keyPressEvent for tableView only for MainWindow (it doesn't recognize tableView or textEdit).

Thank's in advance.