[ Android ] How make keyboard hide trigger QLinedEdit finished ?



  • I am saving QLineEdit text in a QLineEdit::EditingFinished handler.

    One Android, how can I make closing the keyboard ( when user presses the triangular down button ) raise the EditingFinished signal?

    The cursor retains focus in QLineEdit. I would like to behave as if enter or tab was pressed. Possible solutions?

    Thanks in advance,

    -Ed



  • Hi Eddie!
    Use QInputMethod:

    #include <QInputMethod>
    QInputMethod * QGuiApplication::​inputMethod() [static]
    QInputMethod::​hide()
    

    Cheers!



  • Oh wait...
    I think I misunderstood you m(
    For clarification: The triangular down button is not provided by your code but by android, right?



  • Ok, sorry. Had a long day ;-)
    This should work:

    #include <QInputMethod>
    
    [slot] void whenKeyboardVisibiliyChanged() {
        if (QGuiApplication::inputMethod()->isVisible()) {
            yourLineEdit->clearFocus();
        }
    }
    
    connect(QGuiApplication::inputMethod(), SIGNAL(visibleChanged(), yourObject, SLOT(whenKeyboardVisibiliyChanged())));
    

    Cheers!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.