ubuntu-phone team mailing list archive
-
ubuntu-phone team
-
Mailing list archive
-
Message #08985
Re: QML How can i store the value an user enters in a variable?
Hi Diogo:
Once the user enters some value in the textfield, you can reference it
outside the textfield by using q1.text
You can also define a property wherever you need, to fill it with your
desired value this way:
property int sum: parseInt(q1.text, 10) + 1000
Is that what you are looking for?
On 08/07/14 22:47, diogo wrote:
> How can i store the value an user enters in a variable?
>
> For example i have this code
>
> |TextField {width: 37; height: 19
> var
> id: q1
> x: 91
> y: 29
> anchors.horizontalCenter: parent.horizontalCenter
> anchors.verticalCenter:
> parent.verticalCenter
> anchors.centerIn: parent
> placeholderText: "0"
> font.pixelSize: 12
> text: ""
> anchors.verticalCenterOffset: 26
> anchors.horizontalCenterOffset: -115
> validator: IntValidator{}
> horizontalAlignment: TextInput.AlignHCenter
> style: TextFieldStyle {
> textColor: "black"
> background: Rectangle { width: 45; height:
> 25; radius: 20.0
>
> color: "#F0EBEB"
> implicitWidth: 40
> implicitHeight: 24
> border.color: "#000000"
> border.width: 1
> }
> }
> onTextChanged: {console.log(parseInt(text,10) +
> 1000)}
> }
> |
>
> can i use the id to later use and make the sum or the multiplication??
> If yes then and how??
>
>
>
>
References