Saturday, April 27, 2013

QPlatformInputContext and virtual keyboard mockup


Imagine that you're developer preferring Qt, and:
  • you convinced your manager to try out Qt/Qt Quick as UI framework for your custom device (cash machine, POS, ticket machine etc.) to port some old app. 
  • it lacks hardware and software keyboard (the original application's hardcoded its keyboard inside so you can't reuse it).
  • main Qt5 modules are working on the target device (QtCore, QtGui, QtQuick) 
  • you have to provide demo of Qt Quick features on such device (animations, transitions, particles).  
  • deadline is yesterday.
  • you know that if you provide some forms with text input fields and virtual keyboard along with animations and other fireworks then the status of the meeting will change from demo/POC to pre-alpha presentation :)
Animations, particles, transitions are very easy to implement (you could also take sources of Qt Cinematic Experience and change according to needs). The only question is - how fast one will be able to implement mockup of virtual keyboard and reuse it in Qt Quick text editors? Of course Qt handles some standard input systems like Maliit or IBus but they have some dependencies (ex. D-Bus, python). Assuming that our platform doesn't have Maliit or IBus services installed, the only way to achieve the goal is to write some virtual keyboard from scratch. Q Platform Abstraction is the best way to resolve our problem. It's not  officially documented yet but it's self-explanatory API simplifies adding some platform specific features to Qt. Following steps will show how to create custom virtual keyboard that will work with all standard Qt editors (Qt Quick and QtWidgets).