Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/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":http://qt-project.org/doc/qt-4.8/qlineedit.html#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)
    {
    this->focusNextChild();
    return false;
    }@


Log in to reply