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)

Tags: BlackBerry Developers

Similar Questions

  • Name of the dynamic property of object in the table based on the value of a variable

    I have two paintings of custom class objects

    var obj1:Object1
    var obj2:Object2
    
    var array1:Array = [obj1[0], obj1[1], ...]
    var array2:Array = [obj2[0], obj2[1], ...]
    

    Object1 has a property named. Name while Object2 has a property named. Title.

    Now I have a common function including cab accepts an array (array1 or array2) and the name of property the object ("Name" or "Title") as input and needs to access this name of the property of the objects in the array:

    function myFunction(arr:Array, fieldName:String)
    {
        arr[0].fieldName  = "xxx";
    }
    

    the problem I have this achievement does not because the code in the function assumes that the property of that object in the table is actually a string "fieldName" while I want to dynamically determine the names of the fields based on the value of this variable, but cannot understand the syntax to do!

    Don't know if I'm clear - hope that makes sense... ;-) Thank you

    Hey p3pp3r,

    I think I understood you. Try the following and see if you get good results:

    function myFunction(arr:Array, fieldName:String)
    {
        arr[0][fieldName]  = "xxx";
    }
    

    Let me know how it turns out. Good luck!

  • dynamically create and addEventListener on the mouse, click

    Hi, I have 9 buttons on the main stage and each has an incremented instance P0001, P0002, P0003 name...

    I'm trying to dynamically create and addEventListener on mouse click for each call, then the function appropriate when the button is clicked, it is I who does not work, I go about it the wrong way? Thank you

    for (var i: int = 1; i < 10; i ++) {}

    var btn1:String="P000"+i.toString();

    var btn11:Object = btn1;

    var ClickBtn:String="Func"+i.toString();

    btn11.addEventListener (MouseEvent.CLICK, ClickBtn);

    i = i + 1;

    }

    function ClickBtn1(event:MouseEvent):void

    {

    trace ("in it1");

    }

    function ClickBtn2(event:MouseEvent):void

    {

    trace ("in it2");

    }

    ......

    Use:

    for (var i: int = 1; i<10; i++)="">

    This ["P000" + String (i)] .addEventListener (MouseEvent.CLICK, this ["ClickBtn" + String (i)]);

    }

  • Dynamically create a file using the variable

    HI, I am facing a problem in creating file on the time of execution using the variable.
    I have a variable file name. In the tab refresh, I wrote a query SELECT TO_CHAR (SYSDATE, 'YYYY, MM, DD') | 'TEST' FOR DOUBLE. I tested the variable and its value is correct.

    I've created an interface allowing to extract the data in the table and store it in the file. I assigned the variable file name in the file.

    Now when I run the interface... the file is created, but the header is created in different file and its name is ambiguous, g (19) and the data are placed in the other file with the name that matches the value of the variable filename...

    It is two ODI creates two files a single header and other data...

    When I run my interface in a package of the file created perfectly... but one i want to use package I want to create a file via the interface only running

    What is the name of the second file? (the file that does not have the name of the variable)

  • API to create new objects in the inventory

    Hi all
    What is the api used to create articles (Master) in the inventory.

    Thank you and best regards,
    Mahesh

    Mahesh,

    Please refer to the following documents.

    Note: 395493.1 - how to use the public APIs for inventory (undocumented)
    https://metalink2.Oracle.com/MetaLink/PLSQL/ml2_documents.showDocument?p_database_id=not&P_ID=395493.1

    Note: 295475.1 - identify the public API to import items, categories and catalogs
    https://metalink2.Oracle.com/MetaLink/PLSQL/ml2_documents.showDocument?p_database_id=not&P_ID=295475.1

    Additionally, you can check [repository integration Oracle | http://irep.oracle.com/].

    Kind regards
    Hussein

  • export from 8i to 11g does not create an object in the default tablespace

    Hello

    I exported and schema from oracle 8i and I try to import it in oracle 11 g in a different architecture (8i is sparc. 11 g is x 86)

    I created a user with default tablespace and tablespace of origin does not exist in this database, but I get the error message;

    IMP-00003: ORACLE error 959

    ORA-00959: tablespace "TS_ARCCLAIMS_DAT" does not exist

    If I create an indexfile and create all the objects by removing the REM of the indexfile I countless errors grouped so I bet that this is not an option.

    This is how the user is created in 11g:

    CREATE THE USER ARCCLAIMS

    IDENTIFIED BY < password >

    DEFAULT TABLESPACE ARCCLAIMS_DAT

    GN_TMP TEMPORARY TABLESPACE

    DEFAULT PROFILE

    RELEASE OF ACCOUNT;

    -2 roles for ARCCLAIMS

    GRANT CONNECT TO ARCCLAIMS;

    RESOURCE GRANT AT ARCCLAIMS;

    ALTER USER ARCCLAIMS ROLE DEFAULT ALL;

    -1 system privilege for ARCCLAIMS

    GRANT UNLIMITED TABLESPACE TO ARCCLAIMS;

    -1 contingent of Tablespace to ARCCLAIMS

    ALTER USER ARCCLAIMS QUOTA UNLIMITED ON ARCCLAIMS_DAT;

    What should I do to have the items to go to the user's default storage space?

    Thank you

    Mario G.

    You can try this:

    Export file DDL extract.

    imp file % = test.dmp = full test/test display y = log y =

    Use the log file to create the table first, and then ignore object creation errors.

    imp file % = test.dmp = full test/test is ignore = y

    EXPLANATION

    ===========

    Doc 1058330.6 - pl DO NOT send a content - it is a violation of your Support contract >

  • How can I create an object for the vista HP 64 bit operating system installation disc?

    My PC shows signs a failure and I want to save my 'operating system', so I can "reinstall it later." Everything I saw in the forums are just consider my manufacturer. My Builder can not handle make me backups. I had to send them back 7 DOA (dead on arrival) and they never gave me a working copy. So in the end I just receive a refund. and geeksquad is way to expensive. so, how do I go about creating a disc of resettlement?

    Also the backup center and repair is more than the option to backup my operating system.

    Hello

    If you have a recovery disk partition hard HP are the people to contact about this

    It's their recovery partiton not microsofts

    and they have their own special way to make the recovery partition recovery disks

    If as you say your backup centers is not more work you can use 3rd party software to make a complete picture pc

    http://www.Acronis.com/homecomputing/products/TrueImage/

    or if you just want to reinstall a new copy of vista, read this:

    borrow a microsoft dvd vista

    Make sure that you borrow the correct 32-bit or 64-bit microsoft dvd to your computer

    they contain all versions of vista

    This is the product key that determines which version of vista is installed

    then get the hp vista drivers

  • Moving an object using the code (php)

    I had the problem of an error message saying "some files on the server may be missing or incorrect" that I got rid of by just comment javascript code that contains the error of muse.

    After doing this, even if the 'home' button which was originally in the bottom of the page has some how went on the side of the time of the session, as shown below

    The problem = page SESSION TIMES

    Screen Shot 2015-05-18 at 1.49.43 pm.png

    How I am able to target this specific button/image and move it to the bottom left as pictured below? (If possible I would like to fill to the bottom of the box to be less compared to where it is as the )

    table height varies)

    Screen Shot 2015-05-18 at 1.48.02 pm.png

    At the bottom of the page, you have already

    According to the advice of David Powers.

    What I'm saying, just add to that, the following line

    document.getElementById('page').style.width = '380px ';

  • 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

  • Create CollectionModel to display the list of objects in af:table

    Hi all

    I CHOSE to use Oracle 10 g with EJB.
    Normally, when I want to view a list of the read data in the database in an af:table, I drag and drop the relevant control data (EJB bean) return object.

    This time, I need to display a java.util.List of dynamically created custom objects in an af:table in the bean managed my the ADF page.
    In order to display the data in the af: table, I need to wrap the data in a CollectionModel.

    I've seen ADF Table through data control CollectionModel Frank Nimphius suggesting to create a POJO where my items list will exist and turn it into a data control.

    However, it does mention how is this possible programmatically.

    Can anyone help?

    Hello

    If you want to create a managed bean model so its just use an ArrayList and provide getter/setter methods. This reference value of the table and the component will ensure that the model works in the table.

    Frank

  • Is possible to name the objects in the HTML code of muse?

    I'm a graphic designer to work whit a programmer to make Web sites. We want to work togher me taking care of him and graphic part work whit code PHP CSS and all other coding things in really offen my programmer, Web sites have to work whit code the HTML of my muse sites and they have a lot of problem to find the names of the objects in the code because muse give them nemes as CFG67 and for him it's really hard to find an object in the Code since I can't give them a few names.

    Therefore, it is possible to give a name to every graphical object, I did Muse?

    Hello

    Please see the post on the forum for the same below.

    Adding Custom id, & css to the elements class

    in the Muse, you cannot change the classes, IDs that are generated by Muse, however you can click on the link below and vote in favour of the idea of introducing this feature of Muse.

    Add id and custom classes

    Concerning

    Vivek

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

  • How to use 'snippets' of the code that I found on jsfiddle

    Hi people,

    I found some code on jsfiddle I would use in my paper EDGE.

    The violin in question is here

    http://jsfiddle.NET/NJwER/26/

    I created an object on the stage and called it "draggable" (according to the name < div > in the example jsfiddle)

    I then copied this following piece of code in the "JavaScript" jsfiddle pane in the "CompositionReady" of my EDGE document code Panel

    {$(function()}

    $("#draggable").draggable ({}

    Helper: function() {}

    Create an invisible div as the assistance programme. It moves and

    follow the cursor as usual.

    Return $('<div></div>').css('opacity',0);

    },

    Drag: function (event, ui) {}

    During flirting, animate the original object

    Follow invisible help with custom acceleration.

    var p = ui.helper.position ();

    $(this) .stop ().animate({)

    top: p.top,.

    left: p.left

    (}, 1000, "easeOutCirc");

    }

    });

    });

    But nothing happens at all. Can someone let me know why it does not work please?

    Thank you

    Tom

    Hi Tom, here ya go.

    Example (for some strange reason, sometimes I have to refresh to flirting at work... hmmm):

    www.timjaramillo.com/code/Edge/drag_ease

    Source:

    www.timjaramillo.com/code/Edge/_source/drag_ease.zip

    The main question is how you were addressing the "draggable" div Since we're inside the dashboard API, you must precede the symbols with "sym", so it should be:

    SYM. $('draggable') .draggable...

    Previously, you had like:

    $("#draggable").draggable...

    Here's the code revised on Stage.compositionReady:

    () yepnope

    {

    Nope:]

    "js/jquery-ui-1.9.2.custom.min.js,"

    "js/jquery.ui.touch-punch.min.js,"

    'css/jquery-ui-1.9.2.custom.min.css '.

    ],

    full: init

    }

    );

    function init() {}

    SYM. $('draggable»).draggable({)

    Helper: function() {}

    Create an invisible div as the assistance programme. It moves and

    follow the cursor as usual.

    Return $(')

    .css('opacity',0) ');

    },

    Drag: function (event, ui) {}

    During flirting, animate the original object

    Follow invisible help with custom acceleration.

    var p = ui.helper.position ();

    $(this) .stop ().animate({)

    top: p.top,.

    left: p.left

    (}, 1000, "easeOutCirc");

    }

    });

    }

  • Create multiple objects using a loop for

    Help, please

    I am newer to AI Scripting.

    I need to create 30 arrow as objects (d0, d1,..., d29) with different lengths.  I can store lengths in an array (' mylength [] ' ")- but I have to copy the same code and more than 30 times?  Can I create an object where the name of the object is a member of another table?  If I could I could run a loop for to create all 30 arrows.

    This is the code I have-

    var d0 = peoplelayer.pathItems.add (); privacy of D0= true;

    D0.setEntirePath ([[0,0], [-16, 12] [-16, 8] [-mylength [0], 8],[-mylength[0],-8],[-16,-8],[-16,-12]]);

    This code has the idea, but it doesn't work - not

    var arrownames = ["d0", "d1", "d2",..., "d29"]

    var arrownames [0] = peoplelayer.pathItems.add (); private of arrownames [0]= true;

    arrownames [0].setEntirePath ([[0,0], [-16, 12] [-16, 8] [-mylength [0], 8],[-mylength[0],-8],[-16,-8],[-16,-12]]);

    Something that could have?

    Hi theBGF.

    var mylength = [5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,105,110,115,120,125,130,135, 140,145,150,155];
    var d = new Array();

    for (i = 0; i<>
        d [i] = app.activeDocument.layers [0].pathItems.add ();
        d [i].setEntirePath ([[0,0], [-16, 12] [-16, 8] [-mylength [i], 8],[-mylength[i],-8],[-16,-8],[-16,-12]]);
    private d [i]= true;
    }

    Try this script.
    You can access arrow object (pathItems) are d [1] d [30].

  • Is it possible to use a statically defined appearance streams in a dynamically created annotation?

    Hello

    I want to create a document with cascade "popups".  Not the popup only integrated text, but an annotation that contains a stream of appearance that sets the text and images.  I am currently using widget annotations based on a push button field.

    Each page of my document has many citations referring to other pages in the document.  When a user hovers over the quote, I want a "popup" appear containing a representation of the destination.  However, as the destination itself will be quotes, I also want the "popup" to contain citations that the user can fly over, triggering another popup, etc.  In this way, a user can navigate the entire document without leaving the page, or by clicking the mouse.

    Of course, with even a small number of citations per page, pre calculation and statically define all these widgets causes a combinatorial explosion, making it slow and very large document.

    Instead, I want to statically define workflow appearance once per document, and then dynamically create annotations and affect the seemingly appropriate flow using JS when the user navigates.

    So far, I created an access point named in the dictionary of names, but I was not able to use it to dynamically set a dynamically created the appearance of a widget annotation workflow.

    Also, I called Doc.getIcon (), passing the AP named, which returns an Icon object.  However, after field.buttonSetIcon () and passing the AP named, the button does not appear the icon.

    Is it possible to use a statically defined appearance streams in a dynamically created annotation?

    Thank you

    Dave

    Using getIcon/buttonSetIcon must work, but you must make sure that the button is set up that it be set in page is not 'Label Only.

    Also, it is best to store the icons of hidden buttons and recover them with buttonGetIcon due to a bug that causes the icons at the level of the document get wiped out when performing a save as operation file.

Maybe you are looking for