Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to set text again in Text::onTextChanged
Forum Updated to NodeBB v4.3 + New Features

How to set text again in Text::onTextChanged

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 910 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • JehyeokJ Offline
    JehyeokJ Offline
    Jehyeok
    wrote on last edited by
    #1

    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?

    p3c0P 1 Reply Last reply
    0
    • JehyeokJ Jehyeok

      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?

      p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      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
      }
      

      157

      JehyeokJ 1 Reply Last reply
      1
      • p3c0P p3c0

        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
        }
        
        JehyeokJ Offline
        JehyeokJ Offline
        Jehyeok
        wrote on last edited by
        #3

        @p3c0 Thansk it works :)

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved