Detecting virtual keyboard open and close events in Symbian^3
Article Metadata
Code Example
Article
Applications running on Symbian touch devices may want to react to software input panel (virtual keyboard) state events; for example, to improve user experience by immediately processing the input after virtual keyboard is dismissed. Qt provides QEvent::CloseSoftwareInputPanel event, but it's sent only after the target widget has lost focus.
This code snippet uses QValueSpaceSubscriber to detect virtual keyboard state changes. The code depends on a Publish and Subscribe key that is only available on Symbian^3 platform.
Usage
#include <QValueSpaceSubscriber>
QValueSpaceSubscriber* vkbState = new QValueSpaceSubscriber("/vkb/state", this);
QObject::connect(vkbState, SIGNAL(contentsChanged()), this, SLOT(handleStateChanged()));
Declaring /vkb/state value state path
Create a new .qcrml file, with following content:
<?xml version="1.0" encoding="UTF-8"?>
<repository target="RProperty" version="" uidName="KPSUidAknFep" uidValue="0x100056de">
<key ref="/vkb/state" int="0x00000004"/>
</repository>
Changes to .pro file
Add the following definitions to .pro file:
CONFIG += mobility
MOBILITY += publishsubscribe
symbian: {
crml.pkg_postrules = "\"pskeydefs.qcrml\" - \"c:/resource/qt/crml/pskeydefs_$${TARGET}.qcrml\""
DEPLOYMENT += crml
}
Above solution tries to avoid these problems by modifying the deployed .qcrml filename to include also the name of the application (TARGET), thus making it unique.
Example project
File:Vkbstatetest qtmobility symbian3.zip (can be self-signed, doesn't use any capabilities)


treinio 13:53, 19 April 2011 (UTC): Seems to work with Swype as well on N8.
Bad idea ...
The pskeydefs.qcrml file would have to be installed in an hardcoded location, therefore only one application can place it there. A second application attempting to copy a new copy at the same location would fail to install.
The only way this would work is if the file is provided by the mobility package itself...
ltomuta 23:54, 7 June 2011 (EEST)
treinio 15:53, 10 June 2011 (EEST): Good point Lucian. I modified the article so that it modifies the deployed .qcrml filename to be unique. It doesn't address the issue of multiple applications installing identical value space path(s), but according to my tests it causes no problems.
treinio 16:33, 10 June 2011 (EEST): Also, if having a .qcrml file is something that application wants to avoid at all costs, check the history of the article, there is a native symbian implementation that requires no additional files to be deployed.