In some applications we need to determine whether the keyboard has appeared. If it does, we sometimes don't want to have a keyboard. We can also use the Software method to make the keyboard disappear. In this article, we'll show you how to implement this.
Import QtQuick 2.0import ubuntu.components 1.1/*! \brief MainView with a Label and Button Elements.*/mainview {//ObjectName for functional testing purposes (autopilot- QT5) ObjectName: "MainView"//note! ApplicationName needs to match the "name" field of the click Manifest ApplicationName: "Inputmethod.liu-xiao-guo"/* The enables the application to change orientation when the device is rotated. The default is False. *///automaticorientation:true//Removes the old toolbar and enables new features of the new header. Usedeprecatedtoolbar:false width:units.gu (height:units.gu) page {title:i18n.tr ("Inputmethod") Column {spacing:units.gu (2) TextField {id:input} Te XT {text: "Input method:" + "<b>" + Qt.inputMethod.visible + "</b>"} b Utton {text: "Hide Input Method" OnClicked: {Qt.inputMethod.hide (); }}} component.oncompleted: {var keys = Object.keys (Qt.inputmethod); for (var i = 0; i < keys.length; i++) {var key = Keys[i]; Prints all properties, signals, functions from Object Console.log (key + ': ' + Qt.inputmethod[key]); if (key = = = "Locale") {console.log ("Native lang:" + Qt.inputmethod[key].nativelanguagen AME); }} var rect = Qt.inputMethod.keyboardRectangle; Console.log ("Keyboard size:" + rect.width + "" + rect.height); } }}
In the example above, we can see that when the keyboard is not started:
Qt.inputMethod.visible
to False. When the keyboard starts, its value becomes true. Of course, we can also pass the method:
Qt. Inputmethod.hide ();
To make the keyboard disappear.
If the keyboard is turned on in the Ubuntu phone