Handling dynamically created components qml in C++

Hey,.

I dynamically create a qml page by using the following code:

                onClicked: {
                    var favPage = favPageDef.createObject();
                    nav.push(favPage);
                }
                attachedObjects: ComponentDefinition {
                    id: favPageDef
                    source: "FavPage.qml"
                }

I would now like to manipulate the components in this new page qml in c ++. How to access these components?

I was able to access the qml components fairly easily if they were created during the initialization of the application, but of course, this isn't the case.

I discovered what the problem was. I had to do my public AbsractPane in my header file. Then when I created the qml component and calls a function in c ++ it turns out to be a child. Thanks for everyone help well.

Tags: BlackBerry Developers

Similar Questions

  • Help with dynamically created components (turning point properties on or off)

    Hi all! I'm working on an application with a bunch of delegates of control is created dynamically.

    Here's my use case-scenario:

    I do a type app GPA calculator, and instead of hard coding a lot of drop-down lists for students select notes, I created a custom component. According to the documentation, each component created dynamically are destroyed until the parent TI auto is destroyed. ControlDelegate seems to be a better option that you can set the flag to false to make the component to go.  I created a delegate of control that uses the custom of the list drop-down and added a few aliases to give each a name of object on creation. Now, my problem is that I can't understand the correct item call to the property delegateActive set to false to make the element disappear.

    Here is the delegate of the control:

    import bb.cascades 1.2
    
    Container {
        property alias cT : classTitle.text
        property alias oN : obName.text
        property alias dN : dDown.objectName
        property alias cdF : dDown.delegateActive
        property alias dDown : dDown 
    
        topPadding: 10.0
        bottomPadding: 10.0
    
        ControlDelegate {
            id: dDown
            sourceComponent: droDwn
            delegateActive: true
        }
        attachedObjects: [
            ComponentDefinition {
    
                id: droDwn
                GpaDD {
                    ddPro {
                        title: cT
                        objectName: oN
                    }
                }
            }
    
        ]
    
        Label {
            id: classTitle
            text: ""
            visible: false
        }
        Label {
            id: obName
            text: ""
            visible: false
        }
    
        onTouch: {
            console.log(dDown.delegateActive + " " + dDown.objectName)
        }
    }
    

    on the home page, I have the following code to create a new component:

    Page {
        id: gpaCalc
        actions: [
            ActionItem {
                id: addDD
                title: "Add Class"
                imageSource: "asset:///images/add.png"
                ActionBar.placement: ActionBarPlacement.OnBar
    
                onTriggered: {
                    var nn = ddContainer.count();
                    var newDD = defDrop.createObject();
                    newDD.cT = "Class " + [ nn ];
                    newDD.oN = "_" + nn;
                    newDD.dN = "_" + nn;
                    ddContainer.add(newDD);
    
                }
            },
            ActionItem {
                id: remDD
                title: "Remove Class"
                imageSource: "asset:///images/Edit.png"
                ActionBar.placement: ActionBarPlacement.OnBar
    
                onTriggered: {
                    console.log();
                }
    
            }
        ]
        attachedObjects: [
            ComponentDefinition {
                id: defDrop
                DropDelegate {
                }
            }
        ]
        Container {
    
            /* ImageView {
             * horizontalAlignment: HorizontalAlignment.Fill
             * verticalAlignment: VerticalAlignment.Fill
             * imageSource: "asset:///images/rect_overlay.png"
             * opacity: 0.65
             * }*/
            ScrollView {
                horizontalAlignment: HorizontalAlignment.Fill
                verticalAlignment: VerticalAlignment.Fill
                scrollViewProperties {
                    scrollMode: ScrollMode.Vertical
    
                }
                Container {
                    horizontalAlignment: HorizontalAlignment.Fill
                    verticalAlignment: VerticalAlignment.Fill
                    topPadding: 50
                    leftPadding: 50
                    rightPadding: 50
                    id: ddContainer
    
                    onCreationCompleted: {
                        if (ddContainer.count() < 2) {
                            var nn = ddContainer.count();
                            var newDD = defDrop.createObject();
                            newDD.cT = "Class " + [ nn ];
                            newDD.oN = "_" + nn;
                            newDD.dN = "_" + nn;
                            ddContainer.add(newDD);
                        }
                    }
                    Label {
                        text: "Select Your Grades"
                        textStyle.fontStyle: FontStyle.Normal
                        textStyle.fontWeight: FontWeight.W100
                        verticalAlignment: VerticalAlignment.Top
                        horizontalAlignment: HorizontalAlignment.Center
                        textStyle.fontSize: FontSize.XXLarge
                    }
                }
                accessibility.name: "TODO: Add property content"
            }
        }
    }
    

    How can I find the last delegate of control created to define the delegate tag as wrong?

    Any help is appreciated!

    You have so much you need to do it this way?
    Why not just have a placeholder for * each * drop-down list and turn them on and off individually using delegateActive?

  • Align dynamically created components

    I use the custom component shown RemoteImageView here to download the images.

    How to use the component properly in QML?

    I use this code in a loop to create a couple of RemoteImageViews:

    var imageView = remoteImageView.createObject(mainContainer);
    imageView.url = "urltopicture"
    mainContainer.add(imageView);
    

    The component works fine, but all images are stacked on eachother.

    I would like to have a presentation which adds them to the side of the other, ultimately use them as buttons.

    Let your mainContainer have a StackLayout with orientation LeftToRight.

    What you are asking? I guess that's currently a DockLayout

  • [Help] Create components dynamically and its id

    Hello guys.

    I need a help

    I know it sounds weird in the title which precedes but I struggled to find a better solution, but can´t understand it.

    I searched the internet but couldn t find a solution to my problem.

    Here's what I have to do.

    I need to create an order of the day. Each cell must accept a new event or remove an existing event

    The idea is to show all the 365 days of the year. It s important and clearer to the user.

    I ve tried to use the < mx:Repeater > to reproduce a 365 times custom component. He succeeded but I can´t find a way to access these components to change its properties.

    As some of them may have an appointment and others not.

    < mx:HBox horizontalGap = "0" >

    < mx:Repeater id = "monthRepeater" >

    < mx:VBox verticalGap = "0" >

    < mx:Box id = "mes_box" borderColor = "#000000."

    borderStyle = "solid".

    borderThickness = "0.5".

    width = "80" >

    < mx:LinkButton label = "{monthRepeater.currentItem.month}" fontStyle = "normal" fontWeight = "normal" / > "

    < / mx:Box >

    < mx:VBox verticalGap = "0" >

    < mx:Repeater id = "daysRepeater" >

    " < visao:CaixaDia id = linktexto =" {daysRepeater.currentItem.day "day_caixaDia"} "labeltexto =" {daysRepeater.currentIndex} "/ >

    < / mx:Repeater >

    < / mx:VBox >

    < / mx:VBox >

    < / mx:Repeater >

    < / mx:HBox >

    Is it possible to use < mx:Repeater > and dynamically create IDS for these components?

    Thank you

    You can access objects created by a Repeater, as if the id was a table, as in the following example:

    
    
      
        
      
      
      
        
          
        
      
    
    

    If this post answers your question or assistance, please mark it as such.

    Greg Lafrance - Flex 2 and 3 certified ACE

    www.ChikaraDev.com

    Training Flex and Support Services

  • How to dynamically create action item?

    Hi, I want to dynamically create point.

    Before I want to create using qml, but does not seem possible

    http://supportforums.BlackBerry.com/T5/Cascades-development/how-to-create-action-item-of-page-dynami...

    So maybe better to use C++ to create dynamically,

    I'm already try but are still not

    So I have a custom control qml (a Navigation pane)

    name List.qml

    the structure is like this:

    NavigationPane {}

    {Page}

    objectName: myPage

    {Of container

    ....

    }

    }

    }

    How to add action item to this .qml?

    I'm already try that, but failed

    C++ :

    Engine QDeclarativeEngine;

    QDeclarativeComponent component(&engine,QUrl::fromLocalFile("List.qml"));)

    QObject * object = component.create ();

    Page * myPage = object->findChild ("Edit");  Maybe, on that note, I'm wrong implemented? -> not found?

    ActionItem * action1 = ActionItem::create () .title ("first action");

    my page-> addAction (action1, ActionBarPlacement:nBar);

    Remove the object;

    How to create this dynamic Action item?

    Help, please

    Thank you

    Hello

    QML, the object name must be included between "" marks.

    Name of the object of your Page will be:

    objectName: "myPage"
    

    You can reach any CPP QML object like this:

    This excerpt comes from YourProjectName.cpp

    // create scene document from main.qml asset
    // set parent to created document to ensure it exists for the whole
    // application lifetime
    
    QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
    
        // create root object for the UI
        AbstractPane *root = qml->createRootObject();
        // set created root object as a scene
        app->setScene(root);
    
    //and here comes the findChild method
    Page* qmlPage = root->findChild("myPage");
    

    After this, you can create any object on the side of C++ QML, as your own code:

    ActionItem* action1 = ActionItem::create().title("First action");
    myPage->addAction(action1, ActionBarPlacement:nBar);
    

    Don't have no need to create a QObejct, or declarative stuff.

  • Dynamically create QmlComponentDefinition objects in the code

    With QML sample:

    // --- main.qml ---Container {    objectName: "fooContainer"    attachedObjects: [        ComponentDefinition {            id: barComponent            source: "Bar.qml"        }    ]}
    
    // --- Bar.qml ---Container {    objectName: "bar"    Label {        text: "FooBar"    }}
    

    I am trying to dynamically create barComponent objects and add them to fooContainer in C++ code.

    So I reference the using fooContainer:

    fooContainer = createdRootObject->findChild("fooContainer");
    

    But how to reference the definition of QML barComponent to use his method createObject()?

    The definition of the element is used to create the object of QML

    To create the C++ object, you need to do:

    qml = QmlDocument::create("asset:///Bar.qml");
    Control *root =  qml->createRootObject();
    fooContainer->add(root)
    
  • Get the ID of a dynamically created symbol library, inside another symbol.

    Hello world

    I'm trying to get the id of a dynamic created symbol library.

    When you dynamically create the symbol directly on the stage (or the level of the composition), there is no problem.

    But I can not function when you create the symbol inside another symbol.

    A few examples using 'getChildSymbols()' and 'aSymbolInstances '.

    // USING "getChildSymbols()" /////////////////////////////////////////////////////////////////////////

    ON THE STAGE

    var m_item = sym.createChildSymbol ("m_item", "Stage");

    var symbolChildren = sym.getChildSymbols ();

    console.log (symbolChildren [0] .getSymbolElement () .attr ('id')); / / ok eid_1391853893203

    / / Inside a SYMBOL OTHER

    var m_item = sym.createChildSymbol ("m_item", sym.getSymbol("holder").getSymbolElement ());

    var symbolChildren = sym.getSymbol("holder").getChildSymbols (); / / I use this maybe wrong?

    console.log (symbolChildren.Length) / / returns 0 if can't ID is

    ' USE 'aSymbolInstances "".

    ON THE STAGE

    var m_item = sym.createChildSymbol ("m_item", "Stage");

    console.log(sym.aSymbolInstances[0]); / / ok (I guess) x.fn.x.init [1] 0: #eid_1391854141436 div

    / / Inside a SYMBOL OTHER

    var m_item = sym.createChildSymbol ("m_item", sym.getSymbol("holder").getSymbolElement ());

    console.log (sym.getSymbol("holder").aSymbolInstances [0]); / / Error Javascript in the event handler. Type of event = element

    In this post http://forums.Adobe.com/message/5691824 is written: "mySym.aSymbolInstances will give you a table containing all the 'names' when you create symbols"

    Would be - this only works on the scene / composition level only and not inside a symbol?

    The following methods to obtain the same are indeed possible, but I do not simply want to use them in this case:

    (1) storing a reference to the symbol created in a table and call it later by index.

    (2) giving the elements an ID manually on the creation and use of document.getElementById () thereafter.

    I can't believe that this is not possible. I am probably missing something here.

    Forgive me that I am a newbie using Adobe Edge!
    I really hope that someone can help me here.

    Anyway, thnx in advance people!

    Kind regards

    Lester.

    OK, I solved my problem by using the (simple) code below.
    I guess that 'getChildSymbols()' and 'aSymbolInstances' only works on stage / level of the composition.

    Just thought I'd share this to everyone. Peace!

    var m_item = sym.createChildSymbol ("m_item", sym.getSymbol("holder").getSymbolElement ());

    $.each (sym.$("holder").children (), function (index, obj) {}

    Console.log ($(sym.$("holder").) ([Index] Children()) .attr ('id'));

    });

  • Can I dynamically create features on jdeveloper ADF?

    Hello, do you know if it is possible to dynamically generate entities?
    I found examples of dynamically create views, components, etc., but I did find an example or technique to create features of dynamically in the ADF.

    Thanks :)

    Hello

    You must first define a http://docs.oracle.com/cd/B14099_19/web.1012/b14022/oracle/jbo/server/EntityDefImpl.html class. It has a protected method then to create an entity to object

    Frank

  • address dynamically created symbols

    I don't know what is the best way to deal with a specific symbol dynamically created because I don't see in the dashboard API in any way to get the name of the symbol instance. The method . getSymbol() would be the best way to do it, but it takes the name of "instance" symbol and I don't know which one it is. When I use . createChildSymbol() I just pass the name of 'type' symbol and the name of the element parent to put inside but nothing about the symbol instance name that is created. The method . getChildSymbols() doesn't help much because it gets "all" direct children instances are, and I have more of an and of different types.

    I need to get one specific symbol among others that I created dinamcally, so how do I do it better?

    I think on the use of . getChildSymbols() and loop through them all, get the DOM of each symbol with . getSymbolElement(), then use the "class" attribute to at least identify the different types of symbols children recovered. I now have a subset of the children-brothers (symbols of the same type class =) and I can walk through them. At this point, my only hope to distiguish them is the setting of index-z I spent when I created the symbols using the . createChildSymbol().

    Another option would be to 'save' the manager returned to each symbol created with . createChildSymbol() in an object like this {symbol: handler, name: 'no name', created: ' date/time',...} and save them in an array of objects.

    All the best ideas?

    I found something in http://www.edgedocks.com/edgecommons#anchor_edgecommons_21. This guy did a getSymbolName function, which is exactly what we need to solve this problem.

  • Changing the property of all the dynamically created MCs at the same time

    I have a list of dynamically created MCs.  I have this function, which works very well:

    function onLoaded(e:Event):void {
    
         xml = new XML(e.target.data);
         var il:XMLList = xml.channel.item;
         var listItems:Array = new Array();
         for (var i:uint=0; i<il.length(); i++) {
              listItems[i] = new list_item_mc();
              listItems[i].x=0;
              listItems[i].y=i*60;
              listItems[i].list_txt.text = il.description.text()[i];
              listItems[i].addEventListener(MouseEvent.CLICK, listItemClick);
              addChild(listItems[i]);
         }
         
    }
    
    function listItemClick(e:MouseEvent):void {
         e.currentTarget.list_txt.setTextFormat(highlightText);
    }
    

    However, I would like to have this setTextFormat command be run on the list_txt text box in ALL dynamically created MC any ONE of them is clicked on.


    How to achieve this?  The number of dynamically created clips may change at any time, is not a defined number.

    Thank you!

    If you declare the array listItems outside the functions, you can access in your event handler function so that you can loop through it similar to the way you already do in the onLoaded function.

  • When dynamically created variables are emptied in the sequential process template?

    I have a sequence TestStand 2014 in which I dynamically create and fill many FileGlobal variables in the installation section of my main sequence.  I have it using the TestStand API to read the data in an Excel file (the data consists mainly of thresholds, limits, etc.).  The methodology itself works flawlessy.

    However, there are differences in behavior when using entry points both execution of the sequential process model.  When you use the entry point of execution 'Single Pass', he has no problem in test a DUT after another.  However, when you use the entry point for execution "Test DUT", I encounter the following error after completing of DUT1 and DUT2 testing:

    An error occurred the call 'InsertSubProperty' in 'PropertyObject' of 'NI TestStand 2014 API.

    The name of the element "VariableName" is not valid because it is already in use.

    I interpret this error message means that the variable I am trying to dynamically create the DUT2 track is already present race of DUT1.  I have a few questions about this:

    1. at what point in the sequential process template are dynamically created variables flushed, such as run a further by using 'Single Pass' starts with a clean slate?

    2. is there a reminder that I can substitute such as variables to rinse after each HAD run, allowing me to dynamically create variables on each HAD, during execution using "Test UUT?

    3. better yet, is there a counter of TestStand I can query to determine if I already ran DUT1 when using "Test DUT", such as DUT2 uses the variables that were created dynamically on trail of DUT1?

    Or you can simply use the PropertyExists function as a precondition.

    PropertyExists ("Locals.Foo")

  • How to dynamically create variables of StationGlobals who are LabVIEWIOControl

    I'm looking for a way to dynamically create variables StationGlobals LabVIEWIOControl.  I know not how to create variables through "PropertyObject/SetValXXX", however I have some difficualty create variables that are custom data types.

    Thank you

    Bryon

    Bryon,

    You can use an expression as follows:

    StationGlobals.NewSubProperty("MyVariable",PropValType_NamedType,False,"LabVIEWIOControl",0)

    I hope this helps!

  • dynamically create and destroy the custom menu item

    I have a standard TestStand platform that I use on multiple systems.  On some systems, I have a few sequences of calibration and I would like to have the Update menu to have the RunSequence of these sequences of calibration.  I know how to manually create these menu items, but they are no longer valid for some sequence files.  I would use the sequence SequenceFileLoad to dynamically create menu items and the SequenceFileUnload to destroy these menu items.

    I've played around with the API, but cannot determine the correct path to get to the create and destroy the custom menu items.  Does anyone know how this can be done?

    Thank you

    Matthew

    Yes, see the online help for the members of the following APIs:

    Engine.GetEditTimeToolMenuItems

    EditTimeMenuItems

    EditTimeMenuItem

    Basically, you get a collection of tool using Engine.GetEditTimeToolMenuItems () menu items and then call EditTimeMenuItems.Insert () or EditTimeMenuItems.Remove (). If you insert a you get returns an EditTimeMenuItem object on which you can change the settings.

    In addition, since it has an expression to hide items in menu tool, you need not necessarily to destroy, you can hide them instead.

    Hope this helps,

    -Doug

  • Time of design and of the dynamically created controls

    I have a project written in VC6 as a project of the MFC dialog box. In a particular area, I dynamically create several (the exact number depends on user input) CNiGraphs. There is also a two CNiButtons that were created at design time using the resource editor. The problem I have is that when this dialog box is open, a message appears saying it is an eval version and the control will go off after 5 minutes. After 5 minutes of waiting, the CNiButtons 2 go inactive (black tower), but the continuous CNiGraphs of work. I have a valid license of MStudio 8.1.6, version but it seems that these 2 buttons do not recognize the license. There are also other buttons from the moment of conception of the project, but these have no problem at all. When you create the dynamic creation of the CNiGraphs, give them a valid license string, and I was wondering if there is a problem with the time created and dynamically controls created in the same dialog box to design. Anyone know?

    I don't remember, but I can have created these 2 CNiButtons when I was with only an eval license. (All others were undoubtedly create when I got a full license) Could have an impact on them? I have a vague memory of reading somewhere that DTC create controls to check the license when they are created in the designer and store that info in them license. If this is the case does anyone know an easy way to update the license stored in control? I rather not just delete it and Add again because I would avoid having to redo the tab order (unless someone knows how to easily insert something in the middle of the order of tab instead of having to click through all the controls in the correct order)?

    In addition, I don't know if this would affect anything, but the project was originally built with ComponentWorks 1.0, we were forced to move to MStudio when we met a few bugs in CW, so all controls were originally CW controls which have been converted into control of CNi. I doubt that this is so like everywhere else, we changed during controls is not a problem, but I'm ready to try the suggestions.

    Hi JC,.

    I hope you had a good weekend!  I'm glad to hear that you're back running.  Add the extra button was, in fact, causing update the licensing information for the other buttons, as you can imagine.  After further research, I found that the license information are stored only the form of the control, and if this control doesn't change in any way (or in your case, adding a new project), he sees no reason when compiling to recreate a link to the license.  However, after the change of control and a new, it updates the link between the license information, which solved this problem in your case.

    I hope this helps, JC.  Have a great day!

  • dynamically create a database in form 10g

    Hi guys,.

    I got a new requirement, that is to dynamically create a database of blocks and elements...

    How is it possible... ?

    Thank you...

    Ok...

    Thank you

    concerning

    SAI sandeep t

Maybe you are looking for

  • AdBlocker keeps disappearing

    I was glad with no problems for centuries, but he just disappeared one day. As in, he's going to go to work with the small icon in the browser, to be simply missing, no notification, no icon and of course advertising not being blocked, and don't chec

  • Reset - without Apple ID?

    Hi all, I try to reactivate an old I - Phone 4 s. But I forgot the Apple-ID - the delivery has failed. There I have an opinion to reset the i-Phone without the Apple ID and pw? Thank you

  • recovery error code: 0xe0ef0003

    When I tried to recover windows 7 recovery DVD that I created from the recovery partition, I got the error code: 0xe0ef0003 and the PC did not run windows again, so I can't start it anymore, the model is HP G62-121EE... Please help. I think that the

  • HP PROBOOK 450 GB: Can I update my motherboard with a graphics card

    Hello I have a hp probook 450 GB (i3, 8 GB ram, 1 TB), and I wonder if I cand update my motherboard with a graphics card. Is this possible? My motherboard is 1949 Hewlett - Packard (U3E1). Thank you!

  • High memory problem NAC Manager

    Hi guys, I have a failover CAM´s installed. I had seen a high ram memory in the 2 devices use. The use is greater than 80%. Anyone know what is the cause of this memory usage? Also, I have a NAC integrated with these CAM Profiler. Concerning Gerard