Dynamically create qml according to method c ++

In my code c ++ I a QList

QML, I want to show a number of containers that contain information about the particular MyClass as the name.

The list is available with an accessor Get of 2

I use

qml->setContextProperty("class2", class2);

publish the c ++ 2 (extended QObject) to qml.

For the list, I defined a getter with Q_INVOKABLE in the class:

Q_INVOKABLE
QList getMyClasses();

In QML I call it like this:

onCreationCompleted: showMyClasses();
function showMyClasses() {
  var myClasses= class2.getMyClasses();
  console.log("myClasses size: " + myClasses.size());
  for (var i = 0; i < myClasses.size(); i ++) {
     //do stuff
  }
}

But I get:

TypeError: Result of expression 'myClasses' [undefined] is not an object.

This approach is systematically wrong? Or just do something wrong?

In fact, you must save your custom component before you create the same QML file.

Tags: BlackBerry Developers

Similar Questions

  • 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.

  • 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)
    
  • The creation of follow-up to the page dynamically using QML?

    Hi I want to create a dynamic page with QML follow-up

    How to do this?

    Examples or links that explain this?

    Thank you

    Of course, you can dynamically create an ActionItem.

    Page {
        id: page
    
        Container {
            Button {
                text: "Create Action"
                onClicked: {
                    var item = actionTemplate.createObject();
                    item.title = "New Action";
                    page.addAction(item, ActionBarPlacement.OnBar);
                }
            }
        }
    
        attachedObjects: [
            ComponentDefinition {
                id: actionTemplate
                ActionItem {
                    title: 'default'
                    onTriggered: {
                        print('dynamic action item created');
                    }
                }
            }
        ]
    }
    
  • 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.

  • Dynamically creating DataGrid imported .txt file

    I have a tab delimited .txt file exported from Excel which looks like this:

    Sector Section the family Brand Image Description price quantity Code

    Sector 1 Section 1 Description of the Fiat 10000 1 10000 10000 8 25.00 family

    Sector 1 Section 1 1 10001 Kawasaky 10001 Description 10001 10 45.00 family

    Sector 1 Section 1 10002 1 Ford 10002 Description 10002 15 10,00 family

    Sector 1 Section 1 2 10003 Fiat 10003 Description 10003 100 8.00 family

    In this case, I have nine columns, but the method should work with any number of columns.

    The code is developed in Flash Builder, but it's especially AS3.

    I dynamically create a DataGrid from these values. It's my first attempt:

    <? XML version = "1.0" encoding = "utf-8"? >

    " < = xmlns:fx s:Application ' http://ns.Adobe.com/MXML/2009 "

    xmlns:s = "library://ns.adobe.com/flex/spark".

    xmlns:MX = "library://ns.adobe.com/flex/mx".

    creationComplete = "creationCompleteHandler (event)" >

    < fx:Script >

    <! [CDATA]

    import flash.net.URLLoader;

    import flash.net.URLRequest;

    Import mx.collections.ArrayCollection;

    Import mx.controls.DataGrid;

    Import mx.controls.dataGridClasses.DataGridColumn;

    Import mx.events.FlexEvent;

    private var loader: URLLoader = new URLLoader();

    private var request: URLRequest = new URLRequest("txtData/products.txt");

    protected function creationCompleteHandler(event:FlexEvent):void {}

    loader.addEventListener (Event.COMPLETE, loader_complete);

    Loader.Load (request);

    }

    protected function loader_complete(evt:Event):void {}

    Create array of lines in .txt file loaded

    var lines: Array = evt.target.data.split(/\n/);

    var dg:DataGrid = new DataGrid();

    var columns: Array = [];

    var dataProvider:ArrayCollection = new ArrayCollection();

    for (var i: Number = 0; i < lines.length; i ++) {}

    String: var line = lines [i];

    Create array of column values of each row

    var lineArray:Array = line.split(/\t/);

    for (var j: Number = 0; j < lineArray.length; j ++) {}

    var prop: String = lineArray [j];

    {if(i==0)}

    If the first row of the table, create column and assign the value of prop to dataField

    var c:DataGridColumn = new DataGridColumn (prop);

    c.dataField = prop;

    Columns.push (c);

    }

    else {}

    create the new object and add it to the dataProvider

    var dataObject:Object = {area: lineArray [0], Section: lineArray [1], family: lineArray [2], Code: lineArray [3], mark: lineArray [4], Image: lineArray [5], Description: lineArray [6], quantity: lineArray [7], price: lineArray [8]};

    dataProvider.addItem (dataObject);

    }

    }

    }

    assign columns to the dataGrid control

    CGI Columns = columns;

    assign the dataProvider of the dataGrid

    dg.dataProvider = dataProvider;

    Add the DataGrid on stage

    this.addElement (dg);

    }

    []] >

    < / fx:Script >

    < / s:Application >

    I was able to create columns and dataFields dynamically, instead, I wasn't able to do it for the data provider items (see below):

    var dataObject:Object = {area: lineArray [0], Section: lineArray [1], family: lineArray [2], Code: lineArray [3], mark: lineArray [4], Image: lineArray [5], Description: lineArray [6], quantity: lineArray [7], price: lineArray [8]};

    How can I create these values dynamically (without knowing the names number and column data area)?

    Thanks in advance

    use:

    If (i == 0) {}

    for (var j: int = 0; j

    var prop: String = lineArray [j];

    var c:DataGridColumn = new DataGridColumn (prop);

    c.dataField = prop;

    Columns.push (c);

    }

    } else {}

    var dataObject:Object = {};

    for (j = 0; j<>

    dataObject [columns [j] .dataField] = lineArray [j];

    }

    dataProvider.addItem (dataObject);

    }

  • Dynamically create the input text element

    Hello

    I'm trying to dynamically create a text entry and add it to the Table

    but I'm having some problem with createWebBean method we can invoke it.

    Please help thanks
    import oracle.apps.fnd.framework.webui.OAPageContext;
    import oracle.apps.fnd.framework.webui.OAWebBeanConstants;
    import oracle.apps.fnd.framework.webui.beans.OAWebBean;
    import oracle.apps.fnd.framework.webui.beans.message.OAMessageLovInputBean;
    import oracle.apps.fnd.framework.webui.beans.message.OAMessageTextInputBean;
    import oracle.apps.fnd.framework.webui.beans.table.OATableBean;
    import oracle.apps.pa.ci.webui.PaSupplierImplementCO;
    import oracle.apps.pa.util.webui.Debug;
    
     public class xxpaPaSupplierImplementCO extends PaSupplierImplementCO {
    
        public void processRequest(OAPageContext paramOAPageContext,OAWebBean paramOAWebBean) {
            
            super.processRequest(paramOAPageContext, paramOAWebBean);
            xxpaProcessRequest(paramOAPageContext, paramOAWebBean);
        }
        public void xxpaProcessRequest(OAPageContext paramOAPageContext,OAWebBean paramOAWebBean) {
            
            super.processRequest(paramOAPageContext, paramOAWebBean);
            print_log("Start processRequest",paramOAPageContext);
            
            OATableBean localOATableBean = (OATableBean)paramOAWebBean.findIndexedChildRecursive("SupplierTable");
            if (localOATableBean != null){
               OAMessageTextInputBean xxPaPOQuantityBy = (OAMessageTextInputBean)createWebBean(paramOAWebBean,OAWebBeanConstants.MESSAGE_TEXT_INPUT_BEAN,null,"xxPaPOQuantityBy");
               OAMessageTextInputBean xxPaPOQuantityBy1 = (OAMessageTextInputBean)createWebBean(paramOAWebBean,MESSAGE_TEXT_INPUT_BEAN,null,"xxPaPOQuantityBy");
               xxPaPOQuantityBy.setPrompt("Change Quantity By");
               xxPaPOQuantityBy.setMaximumLength(10);
               localOATableBean.addIndexedChild(xxPaPOQuantityBy);
               print_log("PO QTY ADDED ot Supplier Table",paramOAPageContext);
            }
             
            print_log("End processRequest",paramOAPageContext);
        }
    
    }

    Hello

    Try with:

    OAMessageStyledTextBean oamessagestyledtextbean is createWebBean (OAMessageStyledTextBean) (oapagecontext, "MESSAGE_TEXT", null);.

    Concerning
    Meher Irk

  • Dynamically create a Repeater component in ActionScript

    Hello

    I am dynamically creating a repeater with an image control and a label control. I can do it directly in the MXML file but when I try and covert in ActionScript it does not work. You can see what the problem is with my code?

    public void GetPalettes (): void {}
    removeChild (document). FrontPage);
    Palettes.Method = "GET";
    params = {"method": "GetPalettes", "BodyPartNo": document.} PalettesMenu.selectedItem.@partNo};
    Palettes.Cancel ();
    Palettes.Send (params);

    var VerticalBox:VBox = new VBox();
    VerticalBox.x = 10;
    VerticalBox.y = 10;
    VerticalBox.id = "VerticalBox";

    var PaletteRepeater:Repeater = new Repeater();
    PaletteRepeater.dataProvider = "{Palettes.lastResult.Palette}";
    PaletteRepeater.startingIndex = 0;
    PaletteRepeater.id = "PaletteRepeater";

    var PaletteImage:Image = new Image();
    PaletteImage.setStyle ("HorizontalAlign", "left");
    PaletteImage.source = " http://localhost/Flex/Personalised%20Palettes-debug/ {PaletteRepeater.currentItem.@PictureS rc} Med.png"; ""
    PaletteImage.useHandCursor = true;
    PaletteImage.buttonMode = true;
    PaletteImage.mouseChildren = false;
    PaletteImage.id = "PaletteImage";

    var PaletteDescription:Label = new Sun;
    PaletteDescription.text = "{PaletteRepeater.currentItem.@Description}";
    PaletteDescription.id = "PaletteDescription";

    document. MainPage.addChild (VerticalBox);
    VerticalBox.addChild (PaletteRepeater);
    PaletteRepeater.addChild (PaletteImage);
    PaletteRepeater.addChild (PaletteDescription);

    }

    Thank you

    "katychapman85" wrote in message
    News:g6ndvo$5B0$1@forums. Macromedia.com...
    > This is my ActionScript function to get pallets:
    >
    > public void GetPalettes (): void {}
    > document. FrontPage.visible = false;
    > document. PaletteCanvas.visible = false;
    > Palettes.url =
    > "" http://localhost/Flex/Personalised%20Palettes-debug/Palettes.php?BodyPartNo= " "
    > Palettes.url += document. PalettesMenu.selectedItem.@partNo;
    > Palettes.send ();
    > document. PalettePictures.visible = true;
    > }
    >
    >
    > So I to the PalettePictures folded after that I extracted pallets
    > but
    > it still flashes the previous ones. Is the HTTPService has any sort of
    > onComplete parameter so that I can make visible pallets once they have been
    > completely
    > Recovered?

    Try this:

    public void GetPalettes (): void {}
    Palettes.URL =
    "" http://localhost/Flex/Personalised%20Palettes-debug/Palettes.php?BodyPartNo= " "
    Palettes.URL += document. PalettesMenu.selectedItem.@partNo;
    Palettes.Send ();
    Palettes.addEventListener ('Result', onPaletteResult);
    }

    private void onPaletteResult(e:ResultEvent) {}
    Ugh! encapsulation of broken, but I don't know
    enough of your structure to fix
    document. FrontPage.visible = false;
    document. PaletteCanvas.visible = false;
    document. PalettePictures.visible = true;
    }

    HTH;

    Amy

  • Access dynamically created movieclips

    I have an application that I add movieclips to a movieclip container through a loop and repeatedly by calling myClip.addChild (theNewClip). Now I have a dozen of clips in my container and it seems that the only way to access the item is to use the getChildByName() method and run it in a temporary clip, so I can get to the properties.

    What is the best or only way to do this? The old AS2 myContainer ["theName"] .property does not work with dynamically created movieclips? It doesn't seem to work for me.

    In any case, I now get the clips, but I was hoping that someone could show me a better way to access a clip created dynamically.

    OK Yes im a dumass.

    You can just say container.getChildByName("theName").x;

    Do not consider this post lol.

  • TopLink - dynamically create session connection?

    Hi all
    How can PLS, I dynamically create the connection to the database?
    I use toplink workbench and in this step 6: [http://www.oracle.com/technology/products/ias/toplink/doc/11110/tutorial/intro/standalone/intro_tutorial010.htm#CIHIHIFF] I do not check "save the Login and password"...
    If I put the password and static user, everthing works fine, bud I need dynamically created connection... my code is:

    + createSession() protected Sub throws Exception {+
    System.setProperty ("toplink.xml.platform", "oracle.toplink.platform.xml.jaxp.JAXPPlatform");
    XMLSessionConfigLoader loader = new XMLSessionConfigLoader (getSessionsXmlPath ());
    Bishop SessionManager = oracle.toplink.tools.sessionmanagement.SessionManager.getManager ();
    session.setLogin (applyLogin ());
    session = (ServerSession) mgr.getSession (loader, getSessionName(), Thread.currentThread () .getContextClassLoader (), true, true);
    +}+

    + private DatabaseLogin applyLogin() {+
    DatabaseLogin connection = new DatabaseLogin();
    login.usePlatform (new oracle.toplink.platform.database.oracle.Oracle8Platform ());
    login.setDriverClassName ("oracle.jdbc.OracleDriver");
    login.setConnectionString ("path"); JDBC:Oracle:thin:@host:port:SID - path is OK (but SECRET) :-)
    login.setUserName ("user"); USER NAME - user is OK, but hawa ;-)
    login.setEncryptedPassword ("pass"); PASSWORD, ENCRYPTED password is OK ;-)
    Returns the user name;
    +}+

    but he always returns java.lang.NullPointerException! If I set password and user of TopLink workbench, if it works...

    Any ideas, how to configure Java connection, pls?

    SRY for my English...

    Thanks in advance!
    BES cordially, KLD

    Your session variable has the value null until you attribute to him, so you can not call a method on it.

    Try,

    session = (ServerSession) mgr.getSession (loader, getSessionName(), Thread.currentThread () .getContextClassLoader (), false, true);
    session.setLogin (applyLogin ()); \
    session. Login());

    Means that the fake is not to identify the session.

    ----
    James: http://www.eclipselink.org

  • 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!

Maybe you are looking for