[Solved] TextInput: font color change when text changes



  • Hello.

    There is nothing like onChange for the TextInput but only onDisplayDataChanged what didn't work for me.

      TextInput { id: text_input1
                width: 80
                height: 20
                text: qsTr("234234")
                font.pixelSize: 12
                inputMethodHints: Qt.ImhFormattedNumbersOnly
                on???:  {
                    text_input1.color = "#333333"
            }}
    

    And how can I set the same effect for different events, I want to call the same function when on?1 or on?2 or on?3 is called.

    something like
                on?1,on?2,...,.., :  {
                    text_input1.color = "#333333"
            }
    

    but didnt work

    Thank you ;)



  • For every property in QML there is signal on<PropertyName>Changed. So you need onTextChanged.

    For your second question: No. You should write signal handling one by one.



  • Ok, thank you ;)



  • Hi, how did you solve this issue?





  • @VRonin I am using TextEdit

    TableViewColumn {
                    role: "default"
                    title: qsTr("Default Value")
                    width: 150
                    delegate:
                        TextEdit {
                        id:defaultValue
                        text: styleData.value
                    }
                }
    

    When I edit the text, it isn't getting saved. Any idea what i should do?


Log in to reply
 

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