QLineEdit::text 不完整 Android 虚拟键盘
QLineEdit::text is incomplete with Android virtual keyboard
如果我使用Android原生虚拟键盘,QLineEdit
无法获取所有输入的单词。 (Qt 5.7, Android 6)
如果我输入 "Force input"(如图所示)并调用
QLineEdit::text()
我只得到 "Force "。
如何获取全文?
问题是 "input" 仍在 typed/inputted(注意下划线)并且尚未提交给应用程序。您现在可以使用 QInputMethod::commit
:
强制提交所有内容
Commits the word user is currently composing to the editor. The
function is mostly needed by the input methods with text prediction
features and by the methods where the script used for typing
characters is different from the script that actually gets appended to
the editor. Any kind of action that interrupts the text composing
needs to flush the composing state by calling the commit() function,
for example when the cursor is moved elsewhere.
之后,您应该可以使用 QLineEdit::text
检索所有文本。
备选方案:QLineEdit::displayText
正如所讨论的 , it may be possible to use QLineEdit::displayText
没有先调用 QInputMethod::commit
。
如果我使用Android原生虚拟键盘,QLineEdit
无法获取所有输入的单词。 (Qt 5.7, Android 6)
如果我输入 "Force input"(如图所示)并调用
QLineEdit::text()
我只得到 "Force "。
如何获取全文?
问题是 "input" 仍在 typed/inputted(注意下划线)并且尚未提交给应用程序。您现在可以使用 QInputMethod::commit
:
Commits the word user is currently composing to the editor. The function is mostly needed by the input methods with text prediction features and by the methods where the script used for typing characters is different from the script that actually gets appended to the editor. Any kind of action that interrupts the text composing needs to flush the composing state by calling the commit() function, for example when the cursor is moved elsewhere.
之后,您应该可以使用 QLineEdit::text
检索所有文本。
备选方案:QLineEdit::displayText
正如所讨论的 QLineEdit::displayText
没有先调用 QInputMethod::commit
。