Onscreen Keyboard in Qt 5

后端 未结 5 1720
小蘑菇
小蘑菇 2020-12-25 08:45

I want to create a onscreen keyboard for a desktop application. The application will be built in Qt 5. I have couple of questions, please clarify them.

  1. What

5条回答
  •  悲哀的现实
    2020-12-25 09:45

    I understand there are two challenges you would have:

    1. Getting notified as to when to show/hide the on-screen keyboard, based on the focus being on text widgets
    2. How to post key-press event to the text widgets

    ANSWER

    1. As for the former, you could use QObject::InstallEventFilter() on widgets that you want to provide the keyboard service to. You can then look for the mouseReleaseEvent along the lines of the Qt code in the link.
    2. This can be achieved by using QCoreApplication::postEvent()

    As for QPlatformInputContext, get the example of a Qt Virtual Keyboard here.

提交回复
热议问题