[immodule-qt] Does QT 4 beta 1 support IM modules

Lars Knoll lars at trolltech.com
Tue Feb 22 11:52:54 EET 2005


Hi Daisuke,

I went through the problem once again now. I found a rather easy solution to 
the event propagation problem:

If a QInputContext has a parent() that itself is an input context, 
QInputContext::sendEvent will go via the parents sendEvent method instead of 
dispatching the event itself:

void QInputContext::sendEvent(const QInputMethodEvent &event)
{
    // route events over input context parents to make chaining possible.
    QInputContext *p = qobject_cast<QInputContext *>(parent());
    if (p) {
        p->sendEvent(event);
        return;
    }

    QWidget *focus = focusWidget();
    if (!focusWidget())
	return;

    QInputMethodEvent e(event);
    qApp->sendEvent(focus, &e);
}

This should make a proxy input method trivial to implement. 

I also added imsw-multi as the IME switcher now. I might change this in future 
versions of Qt, but this will be the state for Qt 4.0. The changes will be in 
tonights snapshot.

Best regards,
Lars

On Friday 04 February 2005 06:28, Daisuke Kameda wrote:
> On Friday 04 February 2005 01:53, Lars Knoll wrote:
> > I'd like to move the IM switching into Qt itself (I'll try to work on
> > implementing this next week). But this would not affect the API.
>
> I also think so.
>
> BTW, I will also consider a simple switching function
> which accords with your intention.
>
> > > In the sub class of QMultiInputContext, the function to rebuild
> > > QInputMethodEvent may be needed using QInputMethodEvent which slave
> > > generated.
>
> [snip]
>
> > > By implementing this function, usefulness of QMultiInputMethod
> > > increases.
> >
> > But to do so, you would need a way to block the event from being
> > delivered to the widget from the slave input context. Currently the slave
> > context would always directly deliver the event to the widget.
>
> It is right.
>
> Well, I thought other solution. imEventReceived slot is added
> to QInputContext, and QInputContext imEventGenerated signal is
> connected to imEventReceived. Moreover, QInputContext::sendEvent()
> emit imEventGenerated signal by default.
>
> What do you think of this?
>
>
> QInputContext::QInputContext(QObject* parent)
>
>     : QObject(*new QInputContextPrivate, parent)
>
> {
>         QObject::connect( this, SIGNAL(imEventGenerated(QObject
> *,QInputMethodEvent *)),
>                           this, SLOT(imEventReceived(QObject
> *,QInputMethodEvent *)) );
> }
>
> void QInputContext::imEventReceived(QObject *client, QInputMethodEvent
> *event) {
>     QInputMethodEvent e(*event);
>     qApp->sendEvent(client, &e);
> }
>
> void QInputContext::sendEvent(const QInputMethodEvent &event)
> {
>     QWidget *focus = focusWidget();
>     if (!focusWidget())
>         return;
>
>     emit imEventGenerated(focus, &event);
> }



More information about the immodule-qt mailing list