Important: Please read the Qt Code of Conduct -

Change Focus After Enter/ Return Key Pressed in QLineEdit.

  • Hi..

    I am just trying to create a sample Application Form, in that i have few QLineEdits, QCheckBox and QComboBoxes in it. When the user finished Editing in a QLineEdit and if the user Presses the Enter/Return Key, the QLineEdit's Focus has to be changed to the Next Component.. How can i change a QLineEdit's Focus to the next component when an Enter/Return key is Pressed.

    Note: I tried using an Evenfilters() method.. But No use.... :( The Focus is not changing.... :( Please give ur suggestions...

  • QLineEdit has "editingFinished": signal, connect a slot that set the focus to the widget you want.

  • Thanks for your Suggestion Zlatomir.. :)

  • huh.... FocusNextChild itself is working..... :)

    @if(keyEvent->key() == Qt::Key_Enter || keyEvent->key()== Qt::Key_Return)
    return false;

Log in to reply