Qt / KDE and Skim / Xim
Simon Hausmann
hausmann at kde.org
Mon May 28 14:59:25 BST 2007
On Sunday 27 May 2007 21:11:29 Thomas Zander wrote:
> Hiya,
>
> in KOffice I need to port/implement the input method code to allow people
> to input Chinese or even to input normal composited characters.
>
> In my kubuntu kde3 I have a context menu in kmail and in Qts text fields
> to select the input method. "Select Input Method" with submenu items
> like "XIM" and "scim".
>
> Using this menu is essential to start typing in Chinese, for example.
>
> I'm wondering how to do that in KDE in general and in Qt4 when I inherit
> from QWidget in particular.
The menu is the result of a patch distros ship that adds modular input method
plugin support to Qt 3. Scim/uim have plugins that Qt loads directly then for
input method support, instead of going through the ancient xim interface.
In Qt 4 a patch is fortunately not necessary anymore as QInputContext is
public API and Qt by default loads input context plugins. Unfortunately
kubuntu at least does not ship any uim/scim plugins for Qt 4 (uim-qt uses
qt3, despite the package description). So the only way right now to use input
methods in Kubuntu with Qt 4 is through xim.
So Qt comes with input method "plugins" (they're actually compiled in) for
Windows and Mac and with one that uses XIM. In addition there is
src/plugins/inputmethods/imsw-multi which QApplication automatically uses as
default input context if there is more than one input context plugin
installed. The imsw-multi input context is a proxy that provides a QAction
with a sub-menu that allows choosing the current input method. QLineEdit for
example adds that to the context menu using:
#if !defined(QT_NO_IM)
QInputContext *qic = inputContext();
if (qic) {
QList<QAction *> imActions = qic->actions();
for (int i = 0; i < imActions.size(); ++i)
popup->addAction(imActions.at(i));
}
#endif
So this is what you may want to do in your custom input widget, too.
However since there is no shipped qt 4 input method plugin at the moment in
kubuntu at least you can test input method support only through xim
basically. But that works fine for me:
* Install scim, skim and for example scim-tables-additional
* Enable the languages in skim
* set XMODIFIERS to @im=SCIM
* Start a Qt application
* Activate the input method using Ctrl+Space
In order to receive input method events and queries (see
QWidget::inputMethodQuery) you have to set the Qt::WA_InputMethodEnabled
widget attribute.
Simon
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20070528/20f98e02/attachment.sig>
More information about the kde-core-devel
mailing list