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);
}
精彩评论