qt - Intercepting Tab key press to manage focus switching manually -
i want intercept tab key press in main window prevent qt switching focus. here's i've tried far:
bool cmainwindow::event(qevent * e) { if (e && e->type() == qevent::keypress) { qkeyevent * keyevent = dynamic_cast<qkeyevent*>(e); if (keyevent && keyevent->key() == qt::key_tab) return true; } return qmainwindow::event(e); } this doesn't work, event isn't called when press tab. how achieve want?
the elegant way found avoid focus change reimplement in class derived qwidget method bool focusnextprevchild(bool next) , return false. in case want allow it, return true.
like other keys key qt::key_tab in keypressevent(qkeyevent* event)
Comments
Post a Comment