setProperty in pushed NavigationPane Page

How to set the property on the page, which was pushed from NavigationPage?

hand. QML

import bb.cascades 1.0

NavigationPane {
    id: navigationPane
    Button {
        text: qsTr("Game")
        onClicked: {
            navigationPane.push(gameDef.createObject())
        }
    }
    attachedObjects: [
        ComponentDefinition {
            id: gameDef
            source: "game.qml"
        }
    ]

    onPopTransitionEnded: {
        // Destroy the popped Page once the back transition has ended.
        page.destroy();
    }
}

Game.QML

import bb.cascades 1.0

Page {
    property int life: 40000

    //rest correct, not important
}

applicationui.cpp

//fragment
QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
    qml->setContextProperty("app", this);

    // Create root object for the UI
    root = qml->createRootObject();

    root->setProperty("life", int(4));    //not work

What to put in this CPC file, to change the ownership of life in the game.qml file?

Thanks in advance

I think you're going to struggle to write a full app so if you think it takes too much time.

It's not a tip, it's a more condensed way to do what you already do part.

If you do not do it this way it will NEVER work because THERE is NO such thing as the page that you want to access in applicationui.cpp.

[Edit] I have also a problem with findChild as long as you understand its functionality and where and how to use it, then he has a purpose distinct and separate from the definition of property values.

Tags: BlackBerry Developers

Similar Questions

  • NavigationPane pushing a Page several times

    Not sure, which continues, but I have a navigationPane and in the ComponentDefinition, I have another qml page that gets thrust on the navigationPane when the signal of customDefined is called.

    Thus, as soon as the custom signal is triggered, it pushes page in the componentDefinition to the NavigationPane.

    So, now when I click on a listItem which finally triggers the signal customized in QML, he pushes the page very well, but if I come back and click again on the issue, he is now pushing 2 times and now I have to go back 2 times. the number keeps on incrementing at the same time, I click on the listItem.

    BTW, in the page defined in the component definition, it has properties pane that appears when the user clicks on the back of the battery.

    on newspapers, I see the page being skipped too.

    not sure what goes wrong, any help will be appreciated.

    Thank you

    S.

    Hello
    So, I found what the problem was.

    (1)   ListView *listV = root->findChild("listP");
        bool success = QObject::connect(this, SIGNAL(goodForPushPToTest1()), listV, SIGNAL(goodForPush()) );
        emit goodForPushToTest1(); // so, QT signal connected to signal in QML
    

    (1) is the line that caused the problem. the reason being that I create a new object each time and then pushing him to the navPane.

    make sense?

  • Pushing NavigationPane TabbedPane

    I'm trying to push a TabbedPane of NavigationPane (main.qml).

    var nextPage = nav.deprecatedPushQmlByString("tabbedPane.qml");
    

    It does not work. I know either

    (1) I'm doing something wrong

    (2) I do not understand what can or cannot be pushed some screens

    Working mainly in qml.

    I am able to push a 'Page' to NavigationPane. It works without problem.

    Any ideas?

    I too used TabbedPane under NavigationPane in beta 1 of the SDK. Now I just use action buttons to replace the tabbed pane. Here is the explanation of the beta Upgrade Guide 2.

    https://developer.BlackBerry.com/Cascades/documentation/dev/upgrading/index.html

    Adding a TabbedPane to NavigationPane is no longer allowed

    The reason for this change is a tabbed never add to the pages pane child yourNavigationPane. Tabbed browsing should be used only at the top level of your application.

    If you use the deeper navigation and tabbed browsing, you can use NavigationPane in aTabbedPane.

  • Push a page of .qml using C++ defines the Navigation pane.

    If I have a navigation pane, as defined in C++...

    nav =  qml->createRootObject();
    

    How to push a page called page.qml? The only documentation I can find is to build the C++ page, that I don't intend to do. The purpose of the Page doesn't seem to have a constructor that takes a file as input qml Page, so I don't know how to create a Page object to him, pushing with the NavigationPane function-> push(Page*).

    First, you must load the qml file and create the object on the page of the qml. Then push the page in the navigation pane.

    This code can help you!

    NavigationPane *nav_pane = new NavigationPane;
    
    QmlDocument *qml = QmlDocument::create("asset:///MyListView.qml").parent(this);
    Page *new_page = qml->createRootObject();
    nav_pane->push(new_page);
    app->setScene(nav_pane);
    

    -Looks

    Riadh

  • How to make navigation that pushes the page to the side while revealing the links?

    How to make navigation that pushes the page to the side while revealing the links?

    There is currently no way to call JS in reflow, or add some CSS Transitions. You can export the code

    and then open it in a code editor of your choice and add the script necessary to do this. An example is available here: wide canvas Show Menu for Bootstrap model

  • Destroy the NavigationPane Page when used of a Peek

    Hello
    It is possible to destroy a page when the rear sweeping gesture (peek) is used to jump to the page of the NavigationPane? I don't want to use the property ' peekEnabled: false "I like the gesture of glance. I can't use the signal to onPopTransitionEnded I don't know the id of the page that will be skipped (using ComponentDefinition).
    The following is a snippet of the code:

    QML File 1:
    NavigationPane {
            id: navPane
        CustomControlPage{
    
            }
    }
    
    CustomControlPage.qml
    Page{
    ...
    
      onTriggered:{
    // I need to create a new Object everytime and that is causing the  problem when peek gesture is used rather than back button as with backButton, I can just use paneProperties and then do pageID.destroy();
    
        var newPage = newCustomPage.createObject();
        newPage.variant1 = "hello,";
        newPage.variant2 = "world!"
        navPane.push(newPage);
      }
      attachedObjects:[
       ComponentDefinition{
        id: newCustomPage
        source: "newCustomPage.qml"
       }
      ]
    }
    
    newCustomPage.qml
    Page {
     id: newPage
     property variant variant1
     property variant variant2
    ...
    
    paneProperties: NavigationPaneProperties{
      ActionItem{
       title: "Back"
       onTriggered {
          newePage.destroy();
       }
     }
    }
    }
    

    Thank you!

    Yes, that's correct. 'page' is a parameter, it points to the page that you need to destroy.

    popTransitionEnded is called when the page is closed using a "back" button or closed using the gesture of glance.

    It cannot be called if you delete the page programmatically, I'm not sure about this.

  • Pushed QML Page won't scroll

    I push a QML page like this:

    var page = locationPage.createObject();
    nav.push(page);
    

    I have textboxes, webviews, selectors date..., so that they stretch to more than what is visible. The page won't scroll to the property. What can I do?

    I tried to manually set the height for containers, but that did not help.

    Hello
    Place content in the container and wrap it in ScrollView.

    Page {
        ScrollView {
            Container {
              TextField { }
              Button { }
              ...
            }
        }
    }
    
  • How can I add a footer to the main section that will not get push off-page?

    Generator 10.1.2.2.0
    ORACLE Server Release 10.1.0.5.0
    Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64 bit Production

    Hi all

    I want to add a footer frame in the main section of a report that will not get pushed off the page by an extensible framework above it, which can develop vertically, but will still allow the extensible framework continue on the next page (and print another foot on this page as well. I paint a blank on how to do it with anchor or frameworks encompassing etc points.

    Extend the extensible framework until the footer frame. Change the elasticity vertical expandable framework to contract or fixed. In this case, pull-out frame will be printed until the foot of the page and will then continue on the next page.

    I hope this helps.

  • Type calendar settings screen

    Hello!

    I am creating a settings screen that is similar to the system timing application settings screen.

    I created one level then pushed NavigationPane page main screen of the application in this pane.

    When the action parameters is called in the top menu I push settings page in top-level NavigationPane.

    This works well.

    But I need to use TabbedPane as main application screen. From Beta 2 it is not possible to push TabbedPane in NavigationPane. Is there another way to implement this?

    Thank you!

    not sure, the problem, but why can't just use you TabbedPane as your main navigation pane, and then use the NavigationPane for each tab?

    It is a common navigation facility and will reproducce the behavior of native calendar application.

  • Pushing pages in the pages of tabbedPane

    Hello

    I have the following configuration:

    TabbedPane {
        id: tabbedPane
    
        Tab {
            id: tabMembers
            title: qsTr("Members")
            Page1Members {
    
            }
            imageSource: "asset:///images/Members.png"
        }
        Tab {
            id: tabUser
            description: qsTr("Member info")
            Page2User {
                id: pUser
            }
            imageSource: "asset:///images/User.png"
        }
    ...
    

    How to GROW pages in tabs (Page1Members, Page2User)? I need a NavigationPane to push pages, but I don't think that my pages in tabs can be components of navigation...

    Mitch99 wrote:
    I need a NavigationPane to push pages, but I don't think that my pages in tabs can be components of navigation...

    Yes, they can be. Note the hierarchy of classes and the class involved. A TabbedPane holds tabs, which can contain a subclass of AbstractPane. Subclasses of this AbstractPane are NavigationPane, Page and TabbedPane.

  • Referencing the navigationPane parent for push()

    Hello

    I have a NavigationPane with a QML external page as an attachedObject that I push on the screen after clicking on a button.  In the new page, I like to push an another QML external page (it's an attachedObject) on the navigationPane.  How can I reference the second page pushed NavigationPane?  Using the id does not work.  Here is a code:

    NavigationPane:

    NavigationPane {
        id: navigationPane
        Page {
            Container {
                Label {
                    text: "First page"
                }
            }
        }    attachedObjects: [
            SecondPage {
                id: secondPage
            }
    
        ]
        // This gets called on a button click
        function pushSeconPage() {
            navigationPane.push(secondPage);
        }
    }
    

    SecondPage.qml

    Page {
        Container {
            Label {
                text: "Second page"
            }
        }
        attachedObjects: [
            ThirdPage {
                id: thirdPage
            }
        ]
        function pushThirdPage() {
            // How can I reference the original navigationPane to push the
            // third page? This doesn't work...
            navigationPane.push(thirdPage)
        }
    }
    

    I tried to add ThirdPage as an attachedObject in the original navigationPane (rather than have defined it as an attachedObject in secondPage), but it doesn't work anymore.

    Hello

    Assign an id to SecondPage and it's parent will be the NavigationPane:

    secondPageId.parent.push (thirdPage)

  • Push tabbed pane summary pane (Page)

    Hello

    In my application, I have home page that has 3 buttons. When user click on any one of the redirection of the user a button on the screen that has a tabbed pane.

    My main page is the summary pane and have Page as its child object. Now, I want to push the tabs on click of a button pane.

    Is it possible if yes then how we can implement who?

    Thank you

    Megha

    Hi Megha, which can be accomplished by using a sheet in Cascades.  Here is a code example that shows how:

    NavigationPane {
        id: navigationPane
        Page {
            Container {
                layout: StackLayout {
                }
                Button {
                    text: "New Sheet"
                    onClicked: {
                        sheet.open();
                    }
                }
                attachedObjects: [
                    Sheet {
                        id: sheet
                        TabbedPane {
                            showTabsOnActionBar: true
                            Tab {
                                title: "Home"
                                Page {
                                    id: page1
                                    Label {
                                        text: "Tab 1"
                                    }
                                }
                            }
                            Tab {
                                title: "Options"
                                Page {
                                    id: page2
                                    Label {
                                        text: "Tab 2"
                                    }
                                }
                            }
                            Tab {
                                title: "Help"
                                Page {
                                    id: page3
                                    Label {
                                        text: "Tab 3"
                                    }
                                }
                            }
                        }
                    }
                ]
            }
        }
    }
    
  • Push the access and html page locally

    Hello

    I know how to make an html page.

    If I push a page called "myNews.html" store on a remote server.

    My widget on my index.html page, I have a link to the page "myNews.html".

    My problem is I want to open it locally. I don't want to open it from a remote server.

    It should not be in the cache of the browser?

    An application widget/webworks is a sandbox separate from the actual BlackBerry browser.  He does not share the cache of the browser and therefore would not be able to load in your page that is pushed by a surge in browser or the Web for the signals channel.

  • Push of intentional Page with accordion

    Hey everybody,

    So I did some searching around the forum on accordions.
    I see people who have accidentally an accordion that pushes the page and the content down.
    Is there a sure way, or a widget that exists, that will BE intentionally enlarge / reduce the entire page during the interaction of fire?

    Thank you!
    M

    Please provide more details like what exactly you're talking about, uncheck overlap in accordion did the same thing, because it expands and moves other content to the bottom of the page.

    A reference site would be great understand the exact purpose.

    Alternatively, you can try these:

    http://musewidgets.com/search?q=accordion

    Thank you

    Sanjit

  • High level Page object sharing between lower-level components

    I have a QML file that uses a layout similar to the following:

    TabbedPane {
    
        attachedObjects: [
            Page {
                id: resultPage
                Container {
                    Label { text: "This is the result page!" }
                }
                ...
                ...
            },
            ...
        ]
    
        Tab {
            NavigationPane {
                ...
                ...
    
                Button {
                    onClicked {
                        // Change something on resultPage
                        push(resultPage);
                    }
                }
            }
        }
    
        Tab {
            NavigationPane {
                ...
                ...
    
                Button {
                    onClicked {
                        // Change something on resultPage
                        push(resultPage);
                    }
                }
            }
        }
    
    }
    

    I want to be able to make use of a shared Page (resultPage upstairs) between two different NavigationPanes. When I try and push the resultPage on the current NavigationPane, it nothing happens. If I move the object resultPage in table of a particular NavigationPane attachedObjects, pushing this page on the NavPane works very well.

    What is the best way to share a common QML component between two different NavigationPanes? If I had to define resultPage in an external QML file and I had to load into each NavigationPane, would I be able to change things (i.e. the label resultPage) before pushing on the NAV?

    Thank you

    Yes, put resultPage in file separate qml and push through ComponentDefinition (https://developer.blackberry.com/native/reference/cascades/bb__cascades__qmlcomponentdefinition.html...

Maybe you are looking for