×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Regular Contributor
    Join Date
    Jul 2007
    Posts
    139

    How to retrieve parameter which is passed between pages in QML

    Hello,
    I ve found many information how to pass parameter between to different qml pages which are in different qml files but I cannot figure out how to retrieve passed parameter.

    I am using this code to open page and pass parameter:
    Code:
            function loadPage(file, param) {
                var component = Qt.createComponent(file)
                if (component.status === Component.Ready) {
                    if (param !== "")
                        pageStack.push(component, {parameter: param});
                    else
                        pageStack.push(component);
                }
                else
                    console.log("Error loading: " + component.errorString());
            }
    How to retrieve parameter: param in opened page?

  2. #2
    Registered User
    Join Date
    Sep 2011
    Posts
    449

    Re: How to retrieve parameter which is passed between pages in QML

    Hi,

    From documentation -

    pageStack.push(examplePage, { foo: bar, foz: baz });

    This pushes the examplePage onto the stack and set the foo property in the page to bar and the foz property to baz. This can be used both with component or item-based pages.

    in the examplePage.qml, in the Page element you should be accessing them with foo and foz.

  3. #3
    Registered User
    Join Date
    Nov 2011
    Posts
    5

    Re: How to retrieve parameter which is passed between pages in QML

    You have to define a property for the parameter on the Page you are loading. Something like this:

    Code:
    Page {
        id: testPage
    
        property string parameter
    
        Label {
            ...
            text: testPage.parameter
        }
        ...
    }
    So "parameter" is the name of the parameter here. Define the parameters you like as page properties with appropriate name and type.

  4. #4
    Regular Contributor
    Join Date
    Jul 2007
    Posts
    139

    Re: How to retrieve parameter which is passed between pages in QML

    I ve found solution.
    For all new to QML it might be useful to know that foo and foz properties must be declared in examplePage

    property string foo;
    property string foz;

Similar Threads

  1. QE-passed applications (passed 5 days ago) not visible on OVI store
    By MTI500 in forum [Closed] Publishing to Nokia Store
    Replies: 4
    Last Post: 2009-09-03, 17:49
  2. how to retrieve saved pages (.wml pages)
    By karen_cat in forum Browsing and Mark-ups
    Replies: 0
    Last Post: 2005-01-30, 22:23
  3. Replies: 0
    Last Post: 2003-04-29, 15:59
  4. Replies: 0
    Last Post: 2003-04-29, 15:47

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×