update of a drop-down list of QML from C++ fails the first time

Hey gang,

I have a function in my C++ class that seeks a couple of drop downs by ObjectName and their Options adds.

the feature works well - except that when the application first starts, the function cannot find the menu drop-down, then the drop-down list is empty.  At various times during the execution of the application, it refreshes the drop-down list and those all great works.  It is only on the first attempt when the application first starts it fails.

Here's the function:

void WorkManager::updateDropDown() {
//  qWarning() << "WorkManager::updateDropDown(), running..";
/*
 * this function updates the two drop down lists in the UI
 * it updates them dynamically with the taskName() ('label') of the job.
 * NOTE: for some reason, this doesn't find the dropdown's by name on first start.  however subsequent runs work fine.
 */
    int i = 0;
    QList  myObjects = m_model->toListOfObjects();
    DropDown * dpList = bb::cascades::Application::instance()->scene()->findChild("scriptListDropDown");
    DropDown * logDpList = bb::cascades::Application::instance()->scene()->findChild("logDropDown");
    if (dpList != 0 && logDpList !=0 ) {
        dpList->removeAll();
        logDpList->removeAll();
        for (i = 0; i < myObjects.size(); i++) {
            Task * myTask = static_cast (myObjects[i]);
            myTask->setParent(this);
            dpList->add(Option::create().text(myTask->taskLabel()).value(myTask->command()));
            logDpList->add(Option::create().text(myTask->taskLabel()).value(myTask->taskName() + ".log"));
        }
    } else  {
//      qWarning() << "WorkManager::updateDropDown(), ---> dpList was 0, try again";
    }
}

so when the application starts, I get this message of qWarning() and dpList (and logDpList) are both 0.

I tried the dissemination of calls to this function in various places at the same time the C++ class, so in onCreationCompleted() different signals in the QML IU - as for the homepage, TabbedPane, drop-down menus.

No matter where and when I call, I can't get the drop-down list to provide information on the first try.

is there a way to find a way to make this work?  It's (quite) a little annoying.  I wish that the onCreationCompleted() for the drop-down list would work, but alas, no joy.

Help?

Thank you!

J

Quite simply, if the object is not in the scene tree, you will get a result of findChild. It has not been created or added to the scene.

You say that you did above in onCreationCompleted of a drop-down list, but this would only guarantee that one of your drop-down menus has been created and your conditional statement requires that both happening simultaneously be non-null. You must run the above, when the two objects are created.

It seems that you can split the above function to manage separately, the dpList and logDpList after the onCreationCompleted of signals for each drop-down list.

Note: If you run findChild on the user interface of your entire application, your application has a serious design flaw.

Tags: BlackBerry Developers

Similar Questions

  • Have the drop-down list boxes become visible depending on the selection in a previous drop-down list box?

    Hi, im doing a form that only shows some options based on the previous selections.

    So far I have buttons which allow a user to select a specific product, and then by using the drop-down combo boxes select some optional features.

    I then have a simple javascript code that bears the name of a product at a price (i.e. the user selects product 'A', the review sections shows priced at $ 99).

    My problem is with additional customization options that depend on previous choices.

    Is it possible to have some drop-down list boxes become visible depending on the selection in a previous drop-down list box? If yes how could I impliment it?

    Currently my best idea is to have a button that could ask the user if he or she had previously chosen a certain selection and then reveal areas of correct drop-down list accordingly.

    Thank you

    Hello

    With a small change I think that the code works as expected. I changed your mainDD.value to event.value, as on the validate event the mainDD.value property cannot be updated as expected.

    script

    this.getField("Dropdown2").display = display.hidden;

    this.getField("Dropdown3").display = display.hidden;

    this.getField("Dropdown4").display = display.hidden;

    Switch (event.value)

    {

    case "a":

    this.getField("Dropdown2").display = display.visible;

    break;

    case "b":

    this.getField("Dropdown3").display = display.visible;

    break;

    case 'c ':

    this.getField("Dropdown4").display = display.visible;

    break;

    by default:

    break;

    }

    end of script

    Hope this helps

    Malcolm

  • In the drop-down list of fonts, I clicked on the search option, and all my fonts disappeared. How can I disable this feature so that my fonts again?

    I explore my office of the newest version of Adobe InDesign. On the drop-down list of fonts, I clicked on the search item and all my fonts disappeared. How can I turn this option off and get my fonts to appear again?  See below.

    The departure is for your Favorites. If you have any favorite added, the list will be empty.

    The other symbol is for Typekit fonts. If you have not used the fonts in TK, the list is empty.

    Click the TypeKit... looks like he was depressed (clicked on).

    Mike

  • Installed Firefox 17.0.1. Drop-down lists does not open now (like the drop-down list Twitter connection).

    Installed Firefox 17.0.1.

    Drop-down lists will not open now - for example, Twitter login drop-down list (so cannot connect to Twitter). Drop-down lists has worked for all the previous versions of Firefox.

    Its happens very rarely...

    No need to do it each time...

  • I have a drop down list with categories, how to close the categories?

    Hello

    I created the drop-down list categories and in each line, I'll choose a category in the menu dropdown.  How to add each category?

    It's the number 3.6.1 (2566), El Capitan

    That is to say.

    gas

    meal

    Rental

    I want to make the sum of all the lines that are "gas"?

    Use a drop-down menu the right way to do it?

    Thank you

    Edwin

    Hi Edwin,.

    Take a look at the personal Budget template in the template chooser > personal finance.

    SUMIF formulas are in the Budget sheet > summary by the table of categories > column C.

    The drop-down Menus (called context Menus in numbers) are in the leaf of Transactions > column C.

    Make sure spelling is accurate, or numbers will not find a match.

    Please call with questions.

    Kind regards

    Ian.

  • Empty drop down list - planning - Web Forms - Dimensions in the axis of the Page

    Hello

    The drop-down menu that appears when you click on one of the dimension in the axis of the web forms page appears empty. The problem is unique to the single dimension when used with Alias Web form that a single application a plan type and a single instance. The special dimension has more than 1,500 members of level zero and has a seven-digit code and description of words 2 to 5 in the alias.

    I tried to rebuild the shape / LCM for instance different but nothing has worked. I think that this could be attributed to the problem in the JavaScript for menu drop-down. But I have no knowledge on javascripts so abstained.

    Feel free to ask all the questions and thanks in advance.

    Thank you

    RJ

    Finally with the help of the Oracle, I found the problem. The problem was some control characters in the names of aliases which are not visible in the user interface. Somehow these characters in the name of the alias has been added during the transfer files on the remote server or the load control metadata.

    changed ODI reloaded code execution on the target data store, metadata, and the problem is solved.

    See you soon.

  • I have a drop down list with numbers refrence and show the hidden sub

    I have a form that has a drop down menu that has several numbers 1,2,3,4,5,6. I also have a subform hidden with the information that I need to post, so if they want 2 I need 2 instances of this subform to show. If they choose 3 I need 3 instances of this subform to apear. ECT... I have all text flowed and the West.

    Ok. In this case you must first define the instance of the subform, and then you will need to loop through all instances and make these visible subforms.

    In the change event of the DropDownList control, you can put the following script.

    var a = xfa.event.newText; This will capture the value in the case of change, if you want the script to the event exit you have

    AreadDoorMF.instanceManager.setInstances (a);       to make it in the var a this.rawValue

    for (var i = 0; i)

    {

    xfa.resolveNode ("AreaDoorDF [" + i + "]"). DF.presence = "visible";

    xfa.resolveNode ("AreaDoorDF [" + i + "]"). DF. Header.Presence = "visible";

    }

    Sorry I just setInstance instead of setInstances

    Thank you

    Sidonie

  • Drop-down menu which allows free text at the same time?

    Hello experts!

    My users should at the same time a component with a list of values and a free text input text.

    I use Jdev 12.1.2 and I'm triying to reproduce, but I am not in a position:

    https://blogs.Oracle.com/adffun/entry/fun_with_declarative_components?utm_source=dlvr.it & utm_medium = Facebook

    I get an error like:

    Error: < J2EE > < BEA-160187 > < weblogic.appc failed compile the application. Recompile with the option - verbose for more details on this issue. >

    Separator is not a valid child of a choice - mySoc element

    Someone there another example of the requirement, or has been able to use it?

    Thanks in advance,
    Jose.

    Hi Jose,

    The setting of the ADF provides InputComboListOfValues that supports the list of values and free text at the same time, you can also search for and select popup with the InputComboListOfValues

    Thank you

    Shiva Shankar B N

  • How can I make sure after failing the first time, that update for Windows Vista (KB973687) has finally installed successfully?

    I did an update for Windows Vista Service Pack 2 and it has failed with an error code of 80070026. How can I check and see if this update might have gotten resloved?

    Go to start > run > type

    winver

    Click OK

    What Service Pack are told it is installed?

    UTC/GMT is 19:41 Tuesday, January 10, 2012

  • I run Firefox on Mac OX 10.4.11 3.6.19. The component of search engine has now expanded to env.10 inches and adresse_web is now only about 1 inch and full URLS in a drop-down list. I want to restore the previous configuration

    bold text

    You can place the mouse pointer between the address bar and the search bar, and it will become an icon of resizing that you can drag to the right or to the left with the left button of the mouse to change the relative width two bars.

  • How to fill out a drop-down list on the selection of items in another drop-down list using adf 12.1.3

    Hello

    I have a page that has the load drop-down lists and a "submit" button. The first drop down menu got filled using query based VO (IE read only VO) for LOV. The requirement is as below

    -on the selection of an element any in the first drop-down list, the user must fill the second dropdown.

    -Once the second dropdown is completed, the user can select element in the second drop-down list.

    -capture the second drop down menu items value selected in the method of action of the click on the submit button.

    Any help in this scenario will be useful.

    ---

    Rabindranath

    Sameh salvation,

    Thanks for the reply. Your code

    1. DCIteratorBinding iter is BindingContext.getCurrent () .getCurrentBindingsEntry () .get ("iteratorNameInPageDef") (DCIteratorBinding);.
    2. Object secondDropdownValue = iter.getCurrentRow () .getAttribute ("AttributeName");  has been really helpful to get the selected value.

    Thank you very much.

    ---

    Rabindranath

  • Connecting 2 fields drop-down list and have some appear field

    I've read about the binding of the two drop-down lists when you select something in the first box and then it adjusts the options in the second drop-down list box.  I love those who can use in the future.  I have a question a little.

    Can I have two lists that both selections control what fields appear below drop-down list?  For the examples list 1 to A, B and C list 2 has red, Orange and yellow.  I'll choose different combinations of the two and have different things to be displayed.  At Red and has fields 1, 2 and 3 show.  B and yellow display 1 and 3 and so on.

    Is this even possible or do I need to create different combinations all in one field and script the different responses that, I think I know how to do?

    Thank you!

    Hello

    The problem is that you are hiding the subform, BUT you try to assign to the presence of individual boxes in the subform visible. It won't work, because the subform itself is set to hidden.

    Look at the boxes to check and see if you can group them in series that are always hidden or visible. Then script against subforms and NOT the boxes. If you can not group the boxes then you will just have to refer to them individually.

    The textfield object was just a typo.

    Niall

  • Access to a drop-down list item

    Hello

    I have a drop down list in my application. I did it in my QML file. Now, by clicking on a button in the page, I get a pop-up asking for confirmation of the issue, I selected in the drop-down list. How can I get the item I selected in the list and post it? can anyone help pls

    Thank you

    without brackets. This is a property, not a function/method.

  • dynamically load the Options in a drop-down list in C++

    Hey guys,.

    I'm trying to dynamically load items Option in a drop-down list by using C++.  I have a function in my class of WorkManager file that does the trick:

    QStringList WorkManager::getListOfItems() {
        int i = 0;
        QStringList taskNames;  // used for debugging mainly, so i can print the list out to debug
        QList  myObjects = m_model->toListOfObjects();
        DropDown * dpList = bb::cascades::Application::instance()->scene()->findChild("scriptListDropDown");
        if (dpList != 0 ) {
            dpList->setSelectedOption(0);
            dpList->removeAll();
            for (i = 0; i < myObjects.size(); i++) {
                Task * myTask = (Task *) myObjects[i];
                taskNames.append(myTask->taskName());
                dpList->add(Option::create().text(myTask->taskName()).value(myTask->command()));
    //          delete myTask;  // do I need to delete the task object?
            }
    //      qDebug() << "WorkManager::getLIstOfItems(), ---> list of tasks is : " << taskNames;
            return taskNames;
        } else  {
            qDebug() << "WorkManager::getListOfItems(), ---> dpList was 0";
            return taskNames;  // empty list
        }
    }
    

    I also found this thread:http://supportforums.blackberry.com/t5/Native-Development/Adding-options-to-a-DropDown-from-c/m-p/21... that helped me get the filled drop-down list when the application starts.

    However, I need to re - fill list from time to time, when the list (a GroupDataModel) changes.  calling the function above a second time anywhere in my application appears to hang the application immediately.

    I think / thought it might have something to do with the slot for the onSelectedValueChanged, but I can't understand it.

    It seems down right when I do dpList-> removeAll().

    I also can't seem to find the right place to call this function to an object of type in my class.  I think it's because the drop-down list is not ready yet as the dpList * is always 0 unless what I call after the line:

    app->setScene(root);
    

    in the applicationui.cpp file.  Calling it works on start-up, but trying to update the list later (by removeAll() and recreate) causes the app crashing.

    is there a better way to do it?  .. and make it safer?  I can't understand how to do this.

    Thank you!

    J

    First, drop the:

    dpList->setSelectedOption(0);
    

    Not only if it is not necessary, but it will explode your application if the function is called when there is already no options in the menu dropdown.

    Also, do NOT delete the task, because it is still owned by the datamodel. I also see that you use type casting C, which just blindly accepts your cast, even if it's a mistake. Instead, if you know for sure what kind it will be this way instead:

    Task* myTask = static_cast(myObjects[i]);
    

    If you are not sure if the type you are casting the is the type you need, use the dynamic_cast instead:

    Task* myTask = dynamic_cast(myObjects[i]);
    

    The advantage of this more static_cast , is that if you try to perform a type cast is not compatible, then myTask will be set to NULL.

    Alternatively, Qt offers a replacement for dynamic_cast which works on platforms where is not regular C++ casts.

    Task* myTask = qobject_cast(myObjects[i]);
    

    It is functionally equivalent to dynamic_cast, but as I said, it works on all platforms that Qt exists, whereas dynamic_cast cannot.

    Once you did get back to us.

    oddboy wrote:

    Hey guys,.

    I'm trying to dynamically load items Option in a drop-down list by using C++.  I have a function in my class of WorkManager file that does the trick:

    QStringList WorkManager::getListOfItems() {
        int i = 0;
        QStringList taskNames;  // used for debugging mainly, so i can print the list out to debug
        QList  myObjects = m_model->toListOfObjects();
        DropDown * dpList = bb::cascades::Application::instance()->scene()->findChild("scriptListDropDown");
        if (dpList != 0 ) {
            dpList->setSelectedOption(0);
            dpList->removeAll();
            for (i = 0; i < myObjects.size(); i++) {
                Task * myTask = (Task *) myObjects[i];
                taskNames.append(myTask->taskName());
                dpList->add(Option::create().text(myTask->taskName()).value(myTask->command()));
    //          delete myTask;  // do I need to delete the task object?
            }
    //      qDebug() << "WorkManager::getLIstOfItems(), ---> list of tasks is : " << taskNames;
            return taskNames;
        } else  {
            qDebug() << "WorkManager::getListOfItems(), ---> dpList was 0";
            return taskNames;  // empty list
        }
    }
    

    I also found this thread:http://supportforums.blackberry.com/t5/Native-Development/Adding-options-to-a-DropDown-from-c/m-p/21... that helped me get the filled drop-down list when the application starts.

    However, I need to re - fill list from time to time, when the list (a GroupDataModel) changes.  calling the function above a second time anywhere in my application appears to hang the application immediately.

    I think / thought it might have something to do with the slot for the onSelectedValueChanged, but I can't understand it.

    It seems down right when I do dpList-> removeAll().

    I also can't seem to find the right place to call this function to an object of type in my class.  I think it's because the drop-down list is not ready yet as the dpList * is always 0 unless what I call after the line:

    app->setScene(root);
    

    in the applicationui.cpp file.  Calling it works on start-up, but trying to update the list later (by removeAll() and recreate) causes the app crashing.

    is there a better way to do it?  .. and make it safer?  I can't understand how to do this.

    Thank you!

    J

  • Selecting correct state in the drop-down list.

    Here is my delima. I have a form that gets repopulate when users come back to update their contact information. Name, address, etc. of the State. What I am having a problem with performs their State to be selected from a drop-down list. For example, if I'm from Ohio, so I want Ohio selected in the drop-down list. I don't want the user to have to select again the State if the information has not changed. Here's an example of how it is formatted.

    < select tabIndex = "5" name = "State" >
    < option value = "" selected = "selected" > < / option > "
    < option value = 'AL' > Alabama < / option >
    < option value = "AK" > Alaska < / option >
    < option value = "AZ" > Arizona < / option >
    < option value = "AR" > Arkansas < / option >
    < option value = "CA" > California < / option >
    < option value = "CO" > Colorado < / option >

    Of course, the two-letter abbreviation is written and retrieved from the database.
    Everyone works with this before?
    Any help/information is appreciated.
    Brian

    Here's how I made this...

    Top of the page put

    Then, when comes the time to put the list do that...

    I hope this helps.

Maybe you are looking for