aguayro
21st January 2013, 14:47
Hi, need help to know how do a delay row check in a QTableView. When the row changes, the application does some actions, like playing a video. If i select rows keeping key up/down pressed, the application crashes, so i need implement some delay or something to detect if the user has stopped in a row, then start the video.
I was thinking about use EventFilter to ignore key up/down press, and catch only whe them are released.
I've tryed with thi code without luck, key press is not ignored:
bool rs_TablaROMS::eventFilter(QObject *objeto, QEvent *evento) {
if (evento->type() == QEvent::KeyPress) {
QKeyEvent *kEvento = static_cast<QKeyEvent *>(evento);
if (kEvento->key() == Qt::Key_Down || kEvento->key() == Qt::Key_Up) {
// do nothing
}
}
if (evento->type() == QEvent::KeyRelease) {
QKeyEvent *kEvento = static_cast<QKeyEvent *>(evento);
if (kEvento->key() == Qt::Key_Return) {
emit doubleClicked(QModelIndex());
}
if (kEvento->key() == Qt::Key_Down || kEvento->key() == Qt::Key_Up) {
qDebug() << "release";
}
}
return QObject::eventFilter(objeto, evento);
}
Key press is not ignored and "release" is actually printed on key press. What i'm doing wrong?
I was thinking about use EventFilter to ignore key up/down press, and catch only whe them are released.
I've tryed with thi code without luck, key press is not ignored:
bool rs_TablaROMS::eventFilter(QObject *objeto, QEvent *evento) {
if (evento->type() == QEvent::KeyPress) {
QKeyEvent *kEvento = static_cast<QKeyEvent *>(evento);
if (kEvento->key() == Qt::Key_Down || kEvento->key() == Qt::Key_Up) {
// do nothing
}
}
if (evento->type() == QEvent::KeyRelease) {
QKeyEvent *kEvento = static_cast<QKeyEvent *>(evento);
if (kEvento->key() == Qt::Key_Return) {
emit doubleClicked(QModelIndex());
}
if (kEvento->key() == Qt::Key_Down || kEvento->key() == Qt::Key_Up) {
qDebug() << "release";
}
}
return QObject::eventFilter(objeto, evento);
}
Key press is not ignored and "release" is actually printed on key press. What i'm doing wrong?