user13846567
user13846567

Reputation: 117

On a password text field I want to apply an option of un-hidden showing of password for the user to check and confirm in qml

Suppose the user fill the text-field with the password and the password is in password format ( i.e echoMode: TextField.Password ) so how can user check whether it's correct or not? How can i un-hide the password on click?

                    TextField {
                        id: loginPassword
                        Layout.preferredWidth:app.width*0.8
                        color:"#ffffff"
                        font.pixelSize: 14*app.scaleFactor
                        echoMode: TextField.Password                  
                        background: Rectangle {
                            implicitWidth: 290*app.scaleFactor
                            implicitHeight: 40*app.scaleFactor
                            radius: 4*app.scaleFactor
                            color: "transparent"
                            border.color: "#ffffff"
                            height: 37*app.scaleFactor
                        }
                    } 

Upvotes: 0

Views: 790

Answers (1)

JarMan
JarMan

Reputation: 8277

You simply need to toggle the echoMode property. You can add a boolean property to control it, if you want.

TextField {
    id: loginPassword

    property bool showText: false

    echoMode: showText ? TextField.Normal : TextField.Password
}

Then when you want to toggle it (like on a mouse press or button click or whatever), just set loginPassword.showText = true.

Upvotes: 1

Related Questions