Btw, just to close this topic off. What I successfully did was:
- subclass QApplication and re-implement notify
- in there check for keypress event
- if received, check if sender was a line edit -> if so, ignore it
- otherwise handle as global key press
try {
if (e
->type
() == QEvent::KeyPress) { // got a keypress event
// was it sent from a line edit?
if (qobject_cast<QLineEdit*>(w) == nullptr) {
// no, handle as global key press
QKeyEvent * ke
= dynamic_cast<QKeyEvent
*>
(e
);
if (SVViewStateHandler::instance().m_geometryView->handleGlobalKeyPress(ke))
return true;
}
}
}
}
catch (Vic3D::Exception &ex) {
ex.writeMsgStackToError();
IBK::IBK_Message("Vic3D::Exception caught.", IBK::MSG_ERROR, FUNC_ID);
}
return false;
}
bool SVDebugApplication::notify( QObject *recv, QEvent *e ) {
try {
if (e->type() == QEvent::KeyPress) {
// got a keypress event
QWidget * w = focusWidget();
// was it sent from a line edit?
if (qobject_cast<QLineEdit*>(w) == nullptr) {
// no, handle as global key press
QKeyEvent * ke = dynamic_cast<QKeyEvent *>(e);
if (SVViewStateHandler::instance().m_geometryView->handleGlobalKeyPress(ke))
return true;
}
}
}
return QApplication::notify( recv, e );
}
catch (Vic3D::Exception &ex) {
ex.writeMsgStackToError();
IBK::IBK_Message("Vic3D::Exception caught.", IBK::MSG_ERROR, FUNC_ID);
}
return false;
}
To copy to clipboard, switch view to plain text mode
Bookmarks