Search code examples
qtqmlqtquickcontrols

QML TextInput : How to detect user has completed typing on the text field


I am new to Qt & QML. I am using QtQuick 2.4. I have TextInput item with a signal defined in a qml file like below:

import QtQuick 2.4

TextInput {
  text: "Text"
  cursorVisible: true

  signal qmlSignal(string msg)
}

I also have a slot tied to the qmlSignal. I want to trigger the signal when user completes typing on the TextInput field or closes my qml page to go to another page in the application.

What is the correct way to acheive this desired functionality ? Is there something like onFocusChanged false that I can detect, & fire the qml signal ?

I tried searching but couldn't get a sample of how to do this in qml


Solution

  • What about the editingFinished() signal?

    This signal is emitted when the Return or Enter key is pressed or the text input loses focus.