Discussion Board

Results 1 to 4 of 4
  1. #1
    Hi,
    I am Shailesh , working on Nokia N8 application.
    I have problem that How to I switch one qml file to anthor qml file onClick image.

  2. #2
    Registered User semlanik's Avatar
    Join Date
    Feb 2011
    Posts
    3
    If you create QML file with Uppercase name like Page1.qml and Page2.qml
    In you app you just load some another main.qml that may contain one of next tips:

    1. the most simple is:
    Code:
    Item {
        Page1 { //this line creates item from Page1.qml
            id:page1
            visible: true
            ...
        }
    
    ...
        Page2 { //this line creates item from Page2.qml
            id:page2
            visible: false
            ...
        }
    }
    and in Page1.qml and Page2.qml you have some button that changes visibility of your page like this:
    Code:
    onClicked: {
        page1.visible = false;
        page2.visible = true;
    }
    2. More difficult method is using loader:
    main.qml will contain only Loader component:
    Code:
    Loader {
        id:someLoader
        source: "path/to/Page1.qml"
    }
    and again in Page1.qml and Page2.qml you have some button that changes loader source
    Code:
    onClicked: {
        someLoader.source= "path/to/Page2.qml"
    }
    Loader variant is perfect for menu based navigation.
    My English is worse, so if something is not clear please ask.)

  3. #3
    Nokia Developer Expert _perza's Avatar
    Join Date
    Jul 2011
    Posts
    14
    Code:
    onClicked: {
        someLoader.source= "path/to/Page2.qml"
    }
    I tried the alternative 2, but I have a problem: how to refer to someLoader from Page1.qml or Page2.qml, as someLoader is in diffrent file (main.qml)? Do I need to set up a Connection between them?

  4. #4
    Nokia Developer Expert _perza's Avatar
    Join Date
    Jul 2011
    Posts
    14
    My mistake, the alternative 2 is OK as such!

    My problem was that I was writing one file and viewing another

Similar Threads

  1. Drawing in QML
    By JeffC55 in forum [Archived] Qt Quick
    Replies: 8
    Last Post: 2011-04-27, 18:22
  2. Qt/3D with QML bindings - "module "Qt3D" is not installed"
    By John de Witt in forum [Archived] Qt SDKs and Tools
    Replies: 0
    Last Post: 2010-10-20, 04:53
  3. Qml to C++
    By cristids in forum Qt
    Replies: 1
    Last Post: 2010-06-14, 15:58
  4. Nokia Qt Sdk 1 RC 1 - No QML Support
    By cristids in forum [Archived] Qt SDKs and Tools
    Replies: 2
    Last Post: 2010-06-11, 12:31

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Nokia Developer aims to help you create apps and publish them so you can connect with users around the world.

京ICP备05048969号  © Copyright Nokia 2013 All rights reserved