Quantcast
Channel: Qt DevNet forums: Qt Quick 1283365070**
Viewing all articles
Browse latest Browse all 4972

Error using states to change between pages

$
0
0
Hi I’m tring to change between pages using states, in a small game. This is what I did: main.qml: Rectangle {     id: root     ......     PagePanel {         id: pagepanel         state: activeState     } ...... } PagePanel.qml: Item {     id: root     width: 360     height: 420       property string activeState: "game"     states: [         State {             name: "menu"             PropertyChanges {                 target: menuPage                 opacity: 1                 restoreEntryValues: true             }         },           State {             name: "game"             PropertyChanges {                 target: gamePage                 opacity: 1                 restoreEntryValues: true             }           }       ]         PageMenu {         id: menuPage         anchors.fill: parent         opacity: 0       //  onGameclick: root.activeState: "game"     }       PageGame {         id: gamePage         anchors.fill: parent         opacity: 0        // onSunClick2: root.activeState: "menu"     } } The problem is if I uncomment lines 34 and 41, I get errors in main.qml line 4: Type PagePanel unavailable          PagePanel {          ^ and in lines 34 and 41 : Expected token `;'             onGameclick: root.activeState: "game"                                          ^ I very newbie in Qml, and I can’t figure out to change states. I also don’t know if this is the best approach, I read about pagestack wich perhaps would be another option ?

Viewing all articles
Browse latest Browse all 4972

Trending Articles