Keyboard device management in QT/E

Source: Internet
Author: User
Reprinted please indicate the source:
Http://www.cnblogs.com/baizx/

The keyboard device is an instance of qwskeyboardhandler in QT. To support a variety of keyboard devices, QT provides the qwskeyboardhandler interface, all kinds of keyboard devices only need to call the processkeyevent function of qwskeyboardhandler after receiving the buttons of the underlying operating system keyboard device to transmit the keyboard information to the QT System, and then the qwsserver delivers the information to the appropriate client. The most important function of qwskeyboardhandler is to provide processkeyevent so that its subclass can call this function to transmit the key code to the QT System. Lists All keyboard drivers preset by QT. For more information, see the QT official help documentation.


Figure 2- 6 Qwskeyboardhandler inheritance relationship diagram

To implement a custom keyboard device, you can inherit qwskeyboardhandler. The main task is to initialize the device and wait for the user to press the key, and pass the information to the QT System.

For specific procedures, refer:

The driver is responsible for the underlying keyboard device. Here, you only need to open the device, listen to the device descriptor, and associate the readable signal with the custom slot, the data can be read directly when the key data is available.


Notifier =
New qsocketnotifier (kbdfd, qsocketnotifier: read, this );

Connect (notifier,
Signal (activated (INT), this, slot (readkeyboarddata ()));

Another part of work is to wait for the user to press the key and pass it to the QT System. See


Data Formats read from the underlying keyboard device may vary. If the input and output interfaces comply with the Linux Standard, no changes are required, but we often have some special key settings, certain conversions are required, which must be completed in this step. Then



Void qwsserver: processkeyevent (intUnicode, IntKeycode, QT: keyboardmodifiersModifiers, BoolIspress, BoolAutorepeat)[Static]


This is a static function, so it can be used directly. The most important of these parameters is the keycode. You need to convert the custom key value to the internal key code of QT, such as QT: key_delete, modifiers is used to combine keys, such as CTRL and shift. The first parameter Unicode is generally useless and can be ignored.

In QT, the keyboard driver is determined by the Environment Variable qws_keyboard. If there is no keyboard driver, the default one is used. If there is one, the user-specified keyboard driver is used in the same way as the mouse device in QT. For details, refer

Http://www.cnblogs.com/baizx/archive/2010/04/08/1707790.html


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.