Hi all,
I am new to qml and i am trying an application based on calculator.
I am trying to perform addition in qml but i was not able to do with it.
From my coding the output is displayed with the first input i give....
For example:for adding two numbers->i am entering "2" in the first input and clicked on "+" button and entering the second input as "6" and when clicked on "=" i am getting the final output as "2".....
Here is my code:
import QtQuick 1.0
import com.nokia.symbian 1.0
Page {
id: mainPage
property string i;
property string a;
property string b;
property string c;
Button {
id: button13
x: 76
y: 447
text: "0"
onClicked: {
i = text
t.text = t.text + i
}
}
Button {
id: button15
x: 76
y: 375
text: "1"
onClicked: {
i = text
t.text = t.text + i
}
}
Button {
id: button2
x: 136
y: 375
text: "2"
onClicked: {
i = text
t.text = t.text + i
}
}
Button {
id: button3
x: 203
y: 375
text: "3"
onClicked: {
i = text
t.text = t.text + i
}
}
Button {
id: button5
x: 76
y: 299
text: "4"
onClicked: {
i = text
t.text = t.text + i
}
}
Button {
id: button6
x: 136
y: 299
text: "5"
onClicked: {
i = text
t.text = t.text + i
}
}
Button {
id: button7
x: 203
y: 299
text: "6"
onClicked: {
i = text
t.text = t.text + i
}
}
Button {
id: button9
x: 76
y: 235
text: "7"
onClicked: {
i = text
t.text = t.text + i
}
}
Button {
id: button10
x: 136
y: 235
text: "8"
onClicked: {
i = text
t.text = t.text + i
}
}
Button {
id: button11
x: 203
y: 235
text: "9"
onClicked: {
i = text
t.text = t.text + i
}
}
Button {
id: button4
x: 136
y: 447
text: "+"
onClicked: {
a = t.text
t.text = ""
b = t.text
c = a + b
}
}
Button {
id: button8
x: 264
y: 299
text: "-"
onClicked: {
t.text = a
a.toString()
t.text = b
b.toString()
c = a - b;
}
Button {
id: button16
x: 0
y: 76
text: "*"
onClicked: {
t.text = a
a.toString()
t.text = b
b.toString()
c = a * b;
}
Button {
id: button12
x: -58
y: 72
text: "/"
onClicked: {
t.text = a
a.toString()
t.text = b
b.toString()
c = a / b;
}
}
TextField {
id: t
x:-188
y:-237
width: 230
height: 50
text: ""
}
}
}
Button {
id: button1
x: 267
y: 447
width: 39
height: 42
text: "="
onClicked: {
t.text = c
}
}
Button {
id: button14
x: 264
y: 235
width: 42
height: 42
text: "C"
onClicked: {
t.text = ""
}
}
}
import QtQuick 1.0
import com.nokia.symbian 1.0
Page {
id: mainPage
property string i;
property string a;
property string b;
property string c;
Button {
id: button13
x: 76
y: 447
text: "0"
onClicked: {
i = text
t.text = t.text + i
}
}
Button {
id: button15
x: 76
y: 375
text: "1"
onClicked: {
i = text
t.text = t.text + i
}
}
Button {
id: button2
x: 136
y: 375
text: "2"
onClicked: {
i = text
t.text = t.text + i
}
}
Button {
id: button3
x: 203
y: 375
text: "3"
onClicked: {
i = text
t.text = t.text + i
}
}
Button {
id: button5
x: 76
y: 299
text: "4"
onClicked: {
i = text
t.text = t.text + i
}
}
Button {
id: button6
x: 136
y: 299
text: "5"
onClicked: {
i = text
t.text = t.text + i
}
}
Button {
id: button7
x: 203
y: 299
text: "6"
onClicked: {
i = text
t.text = t.text + i
}
}
Button {
id: button9
x: 76
y: 235
text: "7"
onClicked: {
i = text
t.text = t.text + i
}
}
Button {
id: button10
x: 136
y: 235
text: "8"
onClicked: {
i = text
t.text = t.text + i
}
}
Button {
id: button11
x: 203
y: 235
text: "9"
onClicked: {
i = text
t.text = t.text + i
}
}
Button {
id: button4
x: 136
y: 447
text: "+"
onClicked: {
a = t.text
t.text = ""
b = t.text
c = a + b
}
}
Button {
id: button8
x: 264
y: 299
text: "-"
onClicked: {
t.text = a
a.toString()
t.text = b
b.toString()
c = a - b;
}
Button {
id: button16
x: 0
y: 76
text: "*"
onClicked: {
t.text = a
a.toString()
t.text = b
b.toString()
c = a * b;
}
Button {
id: button12
x: -58
y: 72
text: "/"
onClicked: {
t.text = a
a.toString()
t.text = b
b.toString()
c = a / b;
}
}
TextField {
id: t
x:-188
y:-237
width: 230
height: 50
text: ""
}
}
}
Button {
id: button1
x: 267
y: 447
width: 39
height: 42
text: "="
onClicked: {
t.text = c
}
}
Button {
id: button14
x: 264
y: 235
width: 42
height: 42
text: "C"
onClicked: {
t.text = ""
}
}
}
To copy to clipboard, switch view to plain text mode
I think i am wrong with a small mistake anyone help me with this so that i can finish my task.
Regards,
Harish
Bookmarks