Qml States or Script..?/..!
-
Dear Friends,
I'm a beginner in Qt/QML. I have an image file like button named NEXT. I have a 5 qml files. I want to change the qml files one by one, when i press the next button. I've created 5 buttons for each 5 qml files and connected using STATES. It works fine.
But i need to show that files with one button. I think i should do it with script. Please help me to solve this.....Thanks in advance. -
Hello,
you can use "Loader":http://developer.qt.nokia.com/doc/qt-4.8/qml-loader.html and in your button add one property:
@
Image {
id: nextproeprty int currentIndex: 0
}
@than onClicked :
@
onClicked: {
next.currentIndex++switch( next.currentIndex ) { case 0: loaderId.source = "your_first_qml_file.qml"; break; case 1: loaderId.source = "your_second_qml_file.qml"; break; .... }
}
@where loaderId is the id of your Loader item.