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

Reply
New Developer
xjhwc
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

Please use plain text.
Developer
simon_hain
Posts: 16,113
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
Please use plain text.
New Developer
xjhwc
Posts: 5
Registered: ‎11-01-2013
My Device: 8900
My Carrier: 8900

Re: How to pass variables in different QML

help
Please use plain text.
Developer
MagnumOpus
Posts: 138
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
Please use plain text.
New Developer
thurask
Posts: 12
Registered: ‎02-15-2013
My Device: BlackBerry Z30

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

...

Please use plain text.