PDA

View Full Version : How to write coding for state transition in qt qml?



harish
19th January 2012, 07:27
Hi all,
I am new to qt qml and i am trying an application in which i am having a two buttons and two pages.

When clicked on each of those buttons it must display a page.

For example:if i click button 1 it should display page1 and if clicked on button 2 it should display page 2 and so on.

I had tried this coding and it does not works.Anyone help me with this to come with the answer.......?


coding:

Button {
id: button1
x: 3
y: 494
text: "A"
state: "State1"

State {
name:"State1"
PropertyChanges { target: page1 }
}
}

Button {
id: button2
x: 101
y: 494
text: "B"
state: "State2"

State {
name: "State2"
PropertyChanges { target: page2 }
}
}


Page {
id: page1
x: 0
y: 80
width: 360
height: 359

TextEdit {
id: text_edit2
x: 133
y: 19
width: 110
height: 42
color: "white"
text: qsTr(" Page 1")
font.family: "Times New Roman"
font.pixelSize: 15
}
}


Page {
id: page2
x: 0
y: 80
width: 360
height: 359

TextEdit {
id: text_edit3
x: 133
y: 19
width: 110
height: 42
color: "white"
text: qsTr(" Page 2")
font.family: "Times New Roman"
font.pixelSize: 15
}


}







Can anyone point out my mistake and provide me with the solution.


Thanks in Advance,
Harish