Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Qml States or Script..?/..!
QtWS25 Last Chance

Qml States or Script..?/..!

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 2 Posters 1.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Maheshwara
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • T Offline
      T Offline
      task_struct
      wrote on last edited by
      #2

      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: next

      proeprty 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.

      "Most good programmers do programming not because they expect to get paid or get adulation by the public, but because it is fun to program."

      • Linu...
      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved