Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Keyboard Initialisation without using the mouse --Deployment
Under Linux I have to deliver an application that does not use the mouse. I believe I setup everything ok, and here is the problem.
On one system, on program startup, the keyboard is active and the Qt MainWindow application recognizes the keyboard input as expected.
On some other Linux systems, including the one on which I am developing, (I am trying different test platforms), the identical Qt from same 4.74 version and identical source code is blocked. By blocked, I mean that the application does not recognize keyboard entries until a) I use the alt-tab to move to another desktop and return, or b) if I click anywhere on active Qt application screen with the mouse, from then on the Qt application recognizes the keyboard.
Any clues as to what I can do to circumvent this initialisation problem? The application is using buttons throughout. Tabbing to the button and hitting enter works once past initialisation.
I am a true beginner in C++ (I come from 25 years of C programming), so I am experiencing a new world of C++ and Qt.
Is this a Qt bug with 4.7.4?
This is my trains of thought, after reading about mouseevents.
a) create a method in MainWindow::InitializeKeyboard() and have that method signal a mouseclick using coordinates of the first button. I believe that by doing this action, it will initialize the Qt code and also the keyboard recognition.
b) Call for help from this forum
c) Both a) and b).
If you can help, I will be grateful. I am already late for resolving this problem.
I have crossposted to Development forum
Thanks in advance
giesbert last edited by
I assume, that the app has no input focus due to some strange reason. If there is input focus on the app, tab could move the focus to any widget, if not, you can even not emulate a mouse event with qt, it will not get the focus then.
But with the physical mouse, the first mouseClick on a button causes focus to be made, Qt is initialized for keyboard and I am there ready to go.
In my method, is this going to work, where tab_1 is my widget?
Am I posting to the right area?
giesbert last edited by
[quote author="lsatenstein" date="1322685918"]
First: This calls the internal mouse event but wil never set the focus to the application, if it is currently on another app. putting the focus between apps is an OS thing.
Second: The keyboard does not need to be initialized. It exists and the OS handles it. The key events are sent to the app, that currently has got the input focus.
I'm not 100 % sure, whether you can tweak in Linux to grab the input focus from an app, on Windows it is impossible as the OS forbids it. The only thing would be to initiate an OS mouse click, which is not possible with Qt, this must be done via OS API.
Good Sunday morning all.
Here is some new information about the inactive keyboard on startup.
It only happens with GRUB3 . If I test with a Linux using grub2 (debian), or older Fedora (14) the keyboard is active.
Otherwise it takes a focus switch at the operating system level, or a mouse-click anywhere after which the keyboard is active.
For example, the problem is with current UBUNTU 10.4.3 and more recent and current version of Fedora (16).
Linux Mint 12 is OK, as is Debian.