开发者

Any example of QInputMethodEvent usage?

Are there any examples of QIn开发者_运维知识库putMethodEvent usage in Qt Applications?

Thanks


Yes, for example when you create your own virtual keyboard.

I saw an example here https://github.com/githubuser0xFFFF/QtFreeVirtualKeyboard

void DeclarativeInputEngine::sendKeyToFocusItem(const QString& text)
{
    qDebug() << "CDeclarativeInputEngine::sendKeyToFocusItem " << text;
    QInputMethodEvent ev;
    if (text == QString("\x7F"))
    {
        //delete one char
        ev.setCommitString("",-1,1);

    } else
    {
        //add some text
        ev.setCommitString(text);
    }
    QCoreApplication::sendEvent(QGuiApplication::focusObject(),&ev);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜