Hi All,
I am having some problems implementing the eventFilter for my QTableView (filled with QStandardtems).
This partially works:
....
//ui->playTableView->installEventFilter(this);
}
{
// Get selected text on keypress event ctrl+e
if (object == ui->playTableView) {
if (e
->type
() == QEvent::KeyPress) { QKeyEvent *keyEvent
= static_cast<QKeyEvent
*>
(e
);
if (keyEvent->key() == Qt::Key_A) {
qDebug() << "CTRL-A Key pressed" << keyEvent->key();
return true;
}
}
}
return true;
}
....
//ui->playTableView->installEventFilter(this);
}
bool MainWindow::eventFilter(QObject *object, QEvent *e)
{
// Get selected text on keypress event ctrl+e
if (object == ui->playTableView) {
if (e->type() == QEvent::KeyPress) {
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(e);
if (keyEvent->key() == Qt::Key_A) {
qDebug() << "CTRL-A Key pressed" << keyEvent->key();
return true;
}
}
}
return true;
}
To copy to clipboard, switch view to plain text mode
But it makes the app very slow, especially filling the QTableView up with data is like 10 times slower.
What I want to accomplish here is to capture the CTRL-A (Select ALL) keystroke as well as the Arrow Up and Arrow Down when the focus is on the QTableView Widget. I want to keep the default behavior, that all rows in the tableview are selected, but I want to disable some QLineEdits if more than on Row is selected.
If a user selects with the mouse it is not a problem, since I can capture the clicked and double clicked. But How to I catch the CTRL-A ??
Can I use QAction for this?
Hope some one can help me, if possible also with some examples.
Thanks in advace!
Bookmarks