No widgets get focus
-
Hi,
I'm developing an application for an embedded device, and want to be able to let the user use a USB keyboard to edit text in QLineEdit objects. However, none of my widgets are receiving focus!
Another prototype-style application I made on the same device has no problem with it - the text cursor appears and keyboard entries get treated just like on-screen entries (which use insert(QString)). But in my new application, this just doesn't happen - none of my widgets get focus. I initially had a problem with buttons getting focus (which makes them look weird) so I set all of them to have the Qt::NoFocus policy, but now even when I remove these statements, still nothing gets focus, and I have no idea why.
My main class is a QMainWindow, whose central widget is a QStackedWidget, if that makes any difference.
Anybody got any ideas?
-
I just left them all at their defaults initially. However, even if I make sure they're all set to StrongFocus by doing this in the constructor:
@
QWidget *p = ui.lineEdit;
do {
p->setFocusPolicy(Qt::StrongFocus);
} while (p = p->parentWidget());
@There's still no joy.
-
Additionally, I do this after construction-time and printed the objectName of each widget I call setFocusPolicy on, and it definitely goes right up to the top QMainWindow.
-
A curious thing - I now have another main window that takes over the screen. When I hide it, the widgets in the original window (that did not have focus before) can now all have focus as normal!
Anybody got any idea what's going on here, and how I get back to a focusable state without having to bring up this other window?
-
Could it be that your original window is for some unknown reason (hard to say why without seeing the whole application code) not active? Try calling setActiveWindow() for it?