Character input in Qt/EmbeddedInternally in the client/server protocol, each key press and key release is sent as a QWSKeyEvent. A QWSKeyEvent contains the following fields:
When the server receives a key event it is sent to each client process which is responsible for processing the key event and sending it to the right window, if any. Key events may come from several different sources.
Keyboard driversA keyboard driver reads data from a device and gives key events to the server. Keyboard drivers can be compiled into the library or loaded as plugins. Running ./configure -help lists the available keyboard drivers. The "tty" driver is enabled in the default configuration. The keyboard drivers all follow the same pattern. They read keyboard data from a device, find out which keys were pressed, and then call the static function QWSServer::processKeyEvent() with the key information. At present, the console keyboard driver also handles console switching (Ctrl+Alt-F1...Ctrl+Alt+F10) and termination (Ctrl+Alt+Backspace). To add a keyboard driver for a new device, subclasses of QWSKeyboardHandler and QKbdDriverPlugin can be written and installed as plugins.
Key event filters (input methods)When the server receives a key event from a keyboard driver, it first passes it through a filter. This can be used to implement input methods, providing input of characters that are not on the keyboard. To make an input method, subclass QWSServer::KeyboardFilter (in src/kernel/qwindowsystem_qws.h) and implement the virtual function filter(). If filter() returns FALSE, the event will be sent to the clients (using QWSServer::sendKeyEvent()). If filter() returns TRUE, the event will be stopped. To generate new key events, use QWSServer::sendKeyEvent(). (Do not use processKeyEvent(), since this will lead to infinite recursion.) To install a keyboard event filter, use QWSServer::setKeyboardFilter(). Currently, only one filter can be installed at a time. Filtering must be done in the server process. The launcher example contains an example of a simple input method, SimpleIM which reads a substitution table from a file.
Pen inputKey events do not need to come from a keyboard device. The server process may call QWSServer::sendKeyEvent() at any time. Typically, this is done by popping up a widget, and letting the user specify characters with the pointer device. Note: the key input widget should not take focus, since the server would then just send the key events back to the input widget. One way to make sure that the input widget never takes focus is to set the WStyle_Customize and WStyle_Tool widget flags in the QWidget constructor. The Qtopia environment contains various input widgets such as Handwriting Recognition and Virtual Keyboard.
|
Publicité
Best OfActualités les plus luesSemaine
Mois
Année
Le Qt Developer Network au hasardLivre blanc de l'outillage de Qt QuickLe Qt Developer Network est un réseau de développeurs Qt anglophone, où ils peuvent partager leur expérience sur le framework. Lire l'article.
CommunautéRessources
Liens utilesContact
Qt dans le magazine |
Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. | Qt 3.2 | |
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD. | ||
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP ! |
Copyright © 2000-2012 - www.developpez.com