开发者

Any example of QInputMethodEvent usage?

开发者 https://www.devze.com 2023-03-14 08:02 出处:网络
Are there any examples of QIn开发者_运维知识库putMethodEvent usage in Qt Applications? ThanksYes, for example when you create your own virtual keyboard.

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

精彩评论

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