Last active
November 9, 2022 04:52
-
-
Save stephenquan/088f19d28d952fd04a6b787d68d0612f to your computer and use it in GitHub Desktop.
AppStudio_20190703_DoubleValidatorTest.qml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import QtQuick 2.12 | |
import QtQuick.Controls 2.15 | |
import QtQuick.Layouts 1.15 | |
Page { | |
Frame { | |
width: parent.width | |
ColumnLayout { | |
width: parent.width | |
Label { | |
text: qsTr("Type in a number between 25 and 75") | |
} | |
Frame { | |
Layout.fillWidth: true | |
background: Rectangle { | |
color: "#ffe" | |
border.color: "#ccc" | |
} | |
RowLayout { | |
width: parent.width | |
TextInput { | |
id: textInput | |
Layout.fillWidth: true | |
validator: DoubleValidator { | |
bottom: 25.0 | |
top: 75.0 | |
} | |
text: "34.5" | |
color: acceptableInput ? "green" : "red" | |
selectByMouse: true | |
} | |
Image { | |
visible: textInput.acceptableInput | |
source: `data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><path stroke="green" d="M13.5 22.142L7.59 16.42l.636-.636L13.5 20.87 26.721 7.8l.637.637z"/></svg>` | |
} | |
Image { | |
visible: !textInput.acceptableInput | |
source: `data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><path stroke="red" d="M23.985 8.722L16.707 16l7.278 7.278-.707.707L16 16.707l-7.278 7.278-.707-.707L15.293 16 8.015 8.722l.707-.707L16 15.293l7.278-7.278z"/></svg>` | |
} | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment