PDA

View Full Version : Showing Android keyboard from QML TextField



MarkoSan
19th January 2016, 19:22
Hi to all!

Inside my Qt/QML app, based on Qt 5.5.1 Opensource Edition, which is being ported from 64bit Ubuntu 14.04 LTS to Android I have QML TextField entity. Now, when the user selects it using toucscreen on Samsung Tab 3 10.1, the Android virtual keyboard should pop up, but it does not.
Is it possible to popup android virtual keyboard using Qt Opensource edition at all or is it possible to pop up Qt virtual keyboard only and therefore I need Qt payed edition? If the first option is possible, then here is my sample code:


TextField
{
width: 384
height: 128

placeholderText: qsTr("Android keyboard test")

focus: true

onTextChanged:
{
print("Text changed");
} // onTextChanged
} // TextField

anda_skoa
19th January 2016, 21:36
The Qt virtual keyboard is intended for systems that don't have a virtual keyboard.
I doubt it would even work on Android which already has one.

Have you tried "forceActiveFocus()" instead of setting the focus property?

Is the QGuiApplicaton::focusObject() the element you think it is?

Cheers,
_

MarkoSan
19th January 2016, 22:17
I've upgraded code to:


TextField
{
width: 384
height: 128

placeholderText: qsTr("Android keyboard test")

focus: true

onTextChanged:
{
print("Text changed");
} // onTextChanged

MouseArea
{
anchors.fill: parent

onClicked:
{
print("clicked");
forceActiveFocus(Qt.MouseFocusReason);
Qt.inputMethod.show();
} // onClicked
} // MouseArea
} // TextField

Debug message "clicked" gets printed out once I touch onto TextField's area, but keyboard is not visible!

Sincerely,
Marko

john_god
20th January 2016, 01:19
Never used TextField but I have an Android app where I use TextInput and it works "out of the box".

anda_skoa
20th January 2016, 06:48
MouseArea
{
anchors.fill: parent

onClicked:
{
print("clicked");
forceActiveFocus(Qt.MouseFocusReason);
Qt.inputMethod.show();
} // onClicked
} // MouseArea
} // TextField


Why would you wan the MouseAra to have keyboard focus?

Cheers,
_