swankster
27th June 2018, 15:58
I have dialog with space and return references. I want to also be able to catch the physical keystrokes on my keyboard. everything appears to be work except for.
key_return, key_space, key_tab, key_enter. I am focusing on key_Return not the numpad key_enter.
the following will not trigger any event for any of the above keys.
.h
protected
void keyPressEvent(QKeyEvent *);
.cpp
void KeyBoard::keyPressEvent(QKeyEvent *event)
{
qDebug()<<"event";
}
I have also tried the following with no event trigger. all other in keystrokes are working fine.
.h
protected
bool eventFilter(QObject *obj, QEvent *event);
.cpp
bool KeyBoard::eventFilter(QObject* obj, QEvent* event)
{
qDebug()<<"event";
if(event->type() == QEvent::KeyPress) {
QKeyEvent *key = static_cast<QKeyEvent *>(event);
qDebug() << "key " << key->key() << "from" << obj;
}
return QObject::eventFilter(obj, event);
}
I have been struggling with this for a couple days now.
key_return, key_space, key_tab, key_enter. I am focusing on key_Return not the numpad key_enter.
the following will not trigger any event for any of the above keys.
.h
protected
void keyPressEvent(QKeyEvent *);
.cpp
void KeyBoard::keyPressEvent(QKeyEvent *event)
{
qDebug()<<"event";
}
I have also tried the following with no event trigger. all other in keystrokes are working fine.
.h
protected
bool eventFilter(QObject *obj, QEvent *event);
.cpp
bool KeyBoard::eventFilter(QObject* obj, QEvent* event)
{
qDebug()<<"event";
if(event->type() == QEvent::KeyPress) {
QKeyEvent *key = static_cast<QKeyEvent *>(event);
qDebug() << "key " << key->key() << "from" << obj;
}
return QObject::eventFilter(obj, event);
}
I have been struggling with this for a couple days now.