TextInput in qml: How to detect that user has completed typing



  • 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 ? I see that there is onEditingFinished(). How can I use onEditingFinished() here ? Can someone pls provide a sample



  • Hi! I guess the editingFinished signal is what you're looking for.



  • Hello @Nelson_Piquet ,

    You can use signal handler like this:

    TextInput {
        text: "Text"
        cursorVisible: true
    
        signal qmlSignal(string msg)
    
        onEditingFinished: {
            qmlSignal (text);
        }
    
        onQmlSignal: {
            console.log(msg)
        }
    }
    


  • @Julien-B thanks a lot


Log in to reply
 

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