Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
New Developer
Posts: 5
Registered: ‎11-01-2013
My Device: 8900
My Carrier: 8900
Accepted Solution

How to pass variables in different QML

main.qml code:

 

import bb.cascades 1.2
TabbedPane {
    id: tabnav
    property string book_path;

                 .........

                            onTriggered: {
                                clearSelection();
                                select(indexPath);
                                var item = dataModel.data(indexPath);
                                if (item) {                                   
                                    book_path=maincfg.bookpath + item.text;  //(there, book_path have Get content )
                                    var kvbookview1=kvbookview.createObject();
                                    nav.push(kvbookview1);  
                                }
                            }
                        }
                        attachedObjects: [
                            ComponentDefinition {
                                id: kvbookview
                                source: "kv_book_view.qml"
                            }
                        ]

                  .........



kv_book_view.qml code:

 

import bb.cascades 1.2
Page {
    id: view;

    .........
    onCreationCompleted: {
        text3.text =???     (how get main.qml 's book_path variables )       
    }

 

thanks

Highlighted
Developer
Posts: 17,026
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: How to pass variables in different QML

create a property on the page and set it when it is created.
like kvbookview1.book_path = book_path

accessing the property of tabnav should also be possible.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
New Developer
Posts: 5
Registered: ‎11-01-2013
My Device: 8900
My Carrier: 8900

Re: How to pass variables in different QML

help
Developer
Posts: 161
Registered: ‎01-03-2013
My Device: n/a
My Carrier: n/a

Re: How to pass variables in different QML

Simon has given you the solution:

 

import bb.cascades 1.2
Page {
    id: view;
    .........
    onCreationCompleted: {
        text3.text = tabnav.book_path 
    }

 

Regards.

If my answer has been useful to you, please, click the button
Developer
Posts: 16
Registered: ‎02-15-2013
My Device: BlackBerry Passport

Re: How to pass variables in different QML

[ Edited ]

xjhwc wrote:

main.qml code:

 

import bb.cascades 1.2
TabbedPane {
    id: tabnav
    property string book_path;

                 .........

                            onTriggered: {
                                clearSelection();
                                select(indexPath);
                                var item = dataModel.data(indexPath);
                                if (item) {                                   
                                    book_path=maincfg.bookpath + item.text;  //(there, book_path have Get content )
                                    var kvbookview1=kvbookview.createObject();
                                    nav.push(kvbookview1);  
                                }
                            }
                        }
                        attachedObjects: [
                            ComponentDefinition {
                                id: kvbookview
                                source: "kv_book_view.qml"
                            }
                        ]

                  .........



kv_book_view.qml code:

 

import bb.cascades 1.2
Page {
    id: view;

    .........
    onCreationCompleted: {
        text3.text =???     (how get main.qml 's book_path variables )       
    }

 

thanks


main.qml:

 

...

attachedObjects: [
                            ComponentDefinition {
                                id: kvbookview
                                source: "kv_book_view.qml"                                    

                                onCreationCompleted {

                                    kvbookview.kvpath = book_path

                                }

                            }
                        ]

...

 

kv_book_view.qml:

 

Page {

property alias kvpath: text3.text

...