Custom Input Method
-
Hello,
I would like to create a custom input method for applications that use the Qt for gui.
What I have learned so far is that I have to subclass the QInputContext (in QT4) and I found this example http://qt-project.org/doc/qt-4.8/tools-inputpanel.html which kind of helps. But is it possible to make other applications use this custom input context without altering the source code?
Thanks for any replies. -
Hi and welcome to devnet,
AFAIK yes, this will require you to create a QInputContextPlugin and then store that plugin in the proper places so Qt can load it.
-
Can you describe your use case with OS and Qt version ?
-
Well I would like to create input method that would automatically substitute abbreviated words with full lenght words. It should work as implementation of "zavpis" which is a system of abbreviations developed for quicker keyboard input in the czech language.
OS: Slackware 14.0
Qt 4.8.2 -
Then you can install the plugin in your distribution Qt's and all application will use it
-
start your application with the environment variable: QT_DEBUG_PLUGINS=1 to see what is happening with the plugins
-
Oh thank you for your patience, QT_DEBUG_PLUGINS=1 revealed that the applications look for implementation of reset() method in the QInputContext subclass which they didnt find. So I just put there simple void reset(){} and it works fine now.
Anyway I think there is a little gap in the documentation as I never read anywhere that the input method plugins would get loaded in any application that has an input widget. I was near thinking that only implementation of XIM protocol would meet my requirements. -
Something strange here, reset is a pure virtual function, so to build your QInputContext inherited class you should have implemented this method.
Did you read the "Plugin Classes" page in the documentation ? Might contain more information.