SoftwareInputPanel with digits only - how?
-
I noticed quite a few apps where developers are using standard SoftwareInputPanel with alphabetics and digits, while user is only required to input digits.
What is the method to call a SoftwareInputPanel that provides entering digits (the one that exists in Nokia devices)?
-
We should call setInputMethodHints on the editor before opening softwareinputpanel.
Example:
editor->setInputMethodHints(Qt::ImhDigitsOnly);
//http://doc.trolltech.com/4.7.1/qt.html#InputMethodHint-enum//and then call below code to open software keypad.
//http://labs.qt.nokia.com/2009/08/31/new-api-for-input-panel-virtual-keyboards
QEvent event(QEvent::RequestSoftwareInputPanel);
QApplication::sendEvent(editor, &event);//to close kepad
QEvent event(QEvent::CloseSoftwareInputPanel);
QApplication::sendEvent(editor, &event);