Important: Please read the Qt Code of Conduct -

How to set text again in Text::onTextChanged

  • I am using Text component as label. And programatically I set text to 'Text component'.
    But, I would like to check input and set what I want again. For instance, take care of decimal point and unit by my customization.

    I tried this. But it didn't work even though I succeed updating of 'text' property.

    onTextChanged: {
    text = "my new changes'
    console.log("onTextChanged" + text)

    Could you help me this?

  • Moderators

    Hi @Jehyeok and Welcome,
    onTextChanged signal handler returns a copy of the changed text which is what your are try to modify and hence it doesn't affect the text of Text component.
    To make it work just set text using id of Text component.
    For eg:

    onTextChanged: { 
      myText.text = "my new changes" // myText = id of Text component

  • @p3c0 Thansk it works :)

Log in to reply