Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt Android: Pressing "Done" does not hide the keyboard

When I write into a line edit using the Android keyboard, and I press the "Done" button (screenshot below), the keyboard does not disappear. This happens even in a newly created project with just a line edit (I tested it).

How can I make "Done" to hide the keyboard?

Please note that I am looking for a developer solution (i.e. programming, not user oriented) and a native way (i.e. C++/Qt, not Java).

I'm using Qt 5.2.0.

enter image description here

like image 821
sashoalm Avatar asked Jan 12 '14 11:01

sashoalm


1 Answers

You have to call the QInputMethod::hide() slot.

C++ Solution

connect(ui->lineEdit, SIGNAL(editingFinished()), QGuiApplication::inputMethod(), SLOT(hide()));

QML Solution

TextInput {
    Keys.onEnterPressed: {
        //...
        Qt.inputMethod.hide()
    }
    Keys.onReturnPressed: {
        //...
        Qt.inputMethod.hide()
    }
}
like image 169
Fernando Pelliccioni Avatar answered Sep 22 '22 19:09

Fernando Pelliccioni