Reputation: 22936
Considering "Property and Method Changes" from here:
TextInput and TextEdit's openSoftwareInputPanel() and closeSoftwareInputPanel() methods have been removed. Use the new Qt.inputMethod property and call Qt.inputMethod.show() Qt.inputMethod.hide() to show and hide the virtual keyboard.
I've written the simple example below.
import QtQuick 2.3
import QtQuick.Window 2.2
Window
{
id: root
visible: true
width: 600
height: 557
Rectangle
{
id: numberInputBox
height: 500
width: 300
border.color: "green"
TextInput
{
id: textInput
font.pixelSize: 20
cursorVisible: true
height: 500
width: 300
MouseArea
{
anchors.fill: parent
onClicked:
{
Qt.inputMethod.show()
console.log("getPrinted")
}
}
}
}
}
Whereas the text from console.log
gets printed, I cannot see any keyboard on screen.
UPDATE:
I tried:
import QtQuick 2.3
import QtQuick.Window 2.2
Window
{
id: root
visible: true
width: 600
height: 557
Rectangle
{
id: numberInputBox
height: 500
width: 300
border.color: "green"
property string numericText
TextInput
{
id: textInput
text: parent.numericText
focus: true
activeFocusOnPress: true
font.pixelSize: 20
cursorVisible: false
MouseArea
{
anchors.fill: parent
onClicked:
{
Qt.inputMethod.show ()
console.log("fsdfsdf")
}
}
}
}
}
Again, the text gets printed but the keypad doesn't get shown. I am on Ubuntu 14.04.1 LTS with Qt 5.4 and QtCreator 3.3.0
Upvotes: 2
Views: 7769
Reputation: 7692
As stated in the comments, the Qt Virtual Keyboard
is only available in top level licensed version of Qt, i.e. the "professional" and "enterprise" ones, as clearly demonstrated by the feature table available at this download page.
"Community edition" (the open source version of Qt) does not include the keyboard. Hence, on desktop systems, physical keyboard is the only available input option. Differently, in mobile platforms, Qt hooks up the native virtual keyboard system by default and there is no need to call Qt.inputMethod
. Given that, the example in the question can be simply rephrased as follows:
import QtQuick 2.3
import QtQuick.Window 2.2
Window
{
id: root
visible: true
width: 600
height: 557
Rectangle
{
id: numberInputBox
height: 500
width: 300
border.color: "green"
property string numericText
TextInput
{
id: textInput
text: parent.numericText
focus: true
activeFocusOnPress: true
font.pixelSize: 20
cursorVisible: false
}
}
}
Executing this example on a WinPhone, Android or iOS device will correctly show the native virtual keyboard as soon as the TextInput
is tapped.
Upvotes: 1
Reputation: 24406
I think that it's because you need to give the TextInput
focus:
focus: true
This works for me on Desktop, where the only way I know of to test this is to use Qt's Virtual Keyboard (and set QT_IM_MODULE=qtvirtualkeyboard
before running the application), as BaCaRoZzo already mentioned. On platforms with native virtual keyboards, such as Android, the explicit call to Qt.inputMethod.show()
isn't necessary.
Upvotes: 0