Catchin Qt::Key_Tab in QLineEdit
I'd appreciate someone pointing me to, or otherwise providing me with, a more in-depth summary about how Qt handles tab events.
For background, I have an application in which I'd like to modify normal tabbing behavior in a context-sensitive way. Depending on broader details of the application state, the tab key would do different thing.
I think I am actually asking a pretty simple question, and if I could understand one specific failure, I think I could finish up from there.
Specifically, under what circumstances does Qt (or under what circumstance does it not) pass tab events forward for processing by the user?
I have a widget based on QLineEdit in which I want to intercept tabs to process myself. The widget works just like I want within a basic app I built just for testing the widget. However, in my real application, tab events never get to the QLineEdit widget. In the test app, one important issue was to setFocusPolicy to Qt::ClickFocus. It seemed that if the underlying processing was expecting to use tab events to navigate between widgets, then the tab events are never passed to QLineEdit at all.
So in the test app (really just a main window with a QGroupBox to hold a couple of the QLineEdit-based widgets) all I had to do was that setFocusPolicy and the tab key presses were then passed to QLineEdit for processing as I wished.
Unfortunately, in my full-blown app, tab keys never get to QLineEdit. I have tried the same setFocusPolicy trick for (hopefully) all possible widgets, but someone is still intercepting the tab events and not passing them to me.
What other sorts of things should I be looking for that would prevent that?
Any pointers much appreciated.
Since tab is handled by Qt for navigation, most things can eat it from you.
You could try to override
virtual bool QApplication::notify(QObject * receiver, QEvent * e)
and it should be possible to see who gets your tab at any given moment.
THere is also
But seems not for lineEdit.
Thanks. Rather disappointing outcome, but at least I now know I wasn't overlooking something simple.