Can not access the context in QML property

So I have an arraydatamodel in the CPP file, I use qml-> setContextProperty (...) to set it up to allow QML to access, the strangest part is, no matter if I put it in navigationPane Page or a container, it keeps saying can't find not variable, but in the same QML in ListView, they can access it without a problem. The other weird part, it is an another QML is able to access it in the tag of the page, the same model.

By default of the Jun 02 9000 REVIEWS asset:///main.qml:24 09:12:59.416 com.example.IntervalTimer1.testDev_ervalTimer1a7a2c2e2.427733134: ReferenceError: can't find variable: eventsModel
By default of the Jun 02 9000 REVIEWS asset:///main.qml:110 09:12:59.416 com.example.IntervalTimer1.testDev_ervalTimer1a7a2c2e2.427733134: ReferenceError: can't find variable: eventsModel

Here is my code

import bb.cascades 1.0

NavigationPane {
    id: navigationPane
    backButtonsVisible: false
    // Javascript definition
    function udpateTotalTimeLabel() {
        console.log("In updateTotalTimeLabel function");
        var totalHour = 0, totalMinute = 0, totalSecond = 0;
        // To debug javascript object print function
        var print = function(o) {
            var str = '';

            for (var p in o) {
                if (typeof o[p] == 'string') {
                    str += p + ': ' + o[p] + '; 
'; } else { str += p + ': {
' + print(o[p]) + '}'; } } return str; } console.log("EventsModel: " + eventsModel.size()); for (var i = 0; i < eventsModel.size(); i ++) { var currentEvent = eventsModel.data([ i ]); console.log("EventsEvent: " + currentEvent["EventName"]); totalHour += currentEvent["EventHour"]; totalMinute += currentEvent["EventMinute"]; totalSecond += currentEvent["EventSecond"]; } if (totalHour < 10) totalHour = "0" + totalHour; if (totalMinute < 10) totalMinute = "0" + totalMinute; if (totalSecond < 10) totalSecond = "0" + totalSecond; totalTimeLabel.text = totalHour + ":" + totalMinute + ":" + totalSecond; } function onDataReady() { console.log("Received DataReady signal"); navigationPane.udpateTotalTimeLabel(); newEventSheet.close(); } Page { id: root titleBar: TitleBar { title: "Interval Timer" } ..... onCreationCompleted: { navigationPane.udpateTotalTimeLabel(); console.log("No of EventsModel: " + eventsModel.size()); console.log("In sheet creationCompleted"); mainObj.dataReady.connect(navigationPane.onDataReady); } }

In the PRC

// Default empty project template
#include "applicationui.hpp"

#include 
#include 
#include 
#include "CountdownTimer.hpp"

using namespace bb::cascades;

ApplicationUI::ApplicationUI(bb::cascades::Application *app)
: QObject(app)
{
    // 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);

    // Initialize the Array Data Model for holding events
    this->eventsModel = new ArrayDataModel();
    // For Testing only
    QVariantMap event;
    event["EventName"] = "Event1";
    event["EventHour"] = "00";
    event["EventMinute"] = "01";
    event["EventSecond"] = "02";
    this->eventsModel->append(event);

    // create root object for the UI
    AbstractPane *root = qml->createRootObject();

    // Registering the QTimer type to QML
    qmlRegisterType("TimerLibrary", 1, 0, "CountdownTimer");

    // Setting the access for QML to member variable
    qml->setContextProperty("eventsModel",this->eventsModel);
    qml->setContextProperty("mainObj",this);

    // set created root object as a scene
    app->setScene(root);
}

.....

void ApplicationUI::refreshData()
{
    emit dataReady();
}

Thank you.

The fixed.

You must call setContextProperty before calling createRootObject.

Tags: BlackBerry Developers

Similar Questions

  • Can not access the context property of the Interior of the ListView checkbox - onCheckedChange event

    I have a context property called "app" that connects to my C++ application. My listview has a box with onCheckedChange event listener. In this method, when I make a call to the C++ side. application app.runAction, the system displays not found error app.

    If I move the box outside the list view, it will correctly trigger app.runAction.

    Can you please take a look? Thank you!

    On the side of C++ on how I set the context property.

    QmlDocument * qml = QmlDocument::create("asset:///main.qml").parent(this);

    If (qml-> {hasErrors())}
    Returns false;
    }

    QML-> setContextProperty ("app", this);

    navigationPane = qml-> createRootObject();
    If (! navigationPane) {}
    Returns false;
    }

    QML side

     

    NavigationPane {}
    ID: nav

    {Page}
    ID: mainPage
    {Of container

    {To ListView

    listItemComponents:]
    {ListItemComponent}
    type: 'point '.
    {Of container

    Checkbox {}
    Determine whether the check box should be checked
    According to a value in the data model
    checked: ListItemData.checked
    onCheckedChanged: {}
    app.testAction ();
    }
    }

    This is a scope issue... I really hope the devs find a way to fix it properly apart from this ugly solution:

    You can solve this problem by setting your app variable in the global object Qt

    NavigationPane {
        id: nav
    
    onCreationCompleted: Qt.app = app
    
    Page {
            id: mainPage
            Container {
    ListView {
    listItemComponents: [
            ListItemComponent {
                            type: "item"
                            Container {
                       CheckBox {
                                    // Determine whether the CheckBox should be checked
                                    // according to a value in the data model
                                    checked: ListItemData.checked
                                    onCheckedChanged: {
                                         app.testAction();
                                         Qt.app.testAction();
                                    }
                                }
    

    all code in a ListItemComponent will suffer from this 'framing' question

  • Lack the profile can not access the Profile Manager, cannot be continued

    Yahoo somehow accessed and changed the settings of my browsers safari and firefox, could not change the settings for search engine default for more than a minute, even remove engine from yahoo wouldn't last a minute, so I deleted firefox, re-uploaded, now my profile is missing...

    I can not access the Profile Manager via the Terminal, I can't do anything, Firefox is not operational at this time and I don't know how to fix it.

    In Mac OS X v10.7 and later versions, the ~/Library folder is a hidden folder.

    • < User > /users//Library/Application Support/Firefox/profiles.ini

    See also:

  • Can not access the recovery on M30 partition

    Hi all

    I use a Toshiba M30. Last week, I uninstalled the old version of Norton Antivus to install the new version of Norton Internet Security. After you have uninstalled the NA, I found that my phone does not work normally. I, therefore, formated C pilot. Then, I could not access the recovery partition to reinstall the OS.

    How can I solve this problem?

    Thank you very much.

    CUONG

    Could you please be a little more clear on the problem.

    You try to use the recovery CD? Why did you format drive C? When you say that you can not access the recovery partition, how are you trying to access? through BACK.

    Sorry, but your question isn't very clear and a bit confusing. Thank you very much

  • Satellite L350: Can not access the recovery partition by pressing 0

    Heya

    I can not access the recovery on a Toshiba L350 Manager. I tried pressing 0 (zero, two of them) at first to access HD-recovery, but nothing happens. Is there something obvious that I'm missing?

    The reason why I want to access is:
    I have a l350 Toshiba with a partially installed windows here. For now, he gets the "starting Windows" and "instalation program's services began" (in Norwegian) which stops with a popupbox saying: "the computer unexpectedly inexplicable, or an unexpected error has occurred. The site amenities cannot procceed. To install Windows, you will need to click ok to restart the computer. Start the installation process. ».

    What started the problem was that during the last part of the installation (after Win7 becomes usable, but above all has been installed), escape was pressed, and the computer has been used normally.

    > I can not access the recovery on a Toshiba L350 Manager. I tried pressing 0 (zero, two of them) at first to access HD-recovery, but nothing happens. Is there something obvious that I'm missing?

    I assume you are using a European model for laptop and so you should try it;
    -Press on F8 laptop computer power on.
    -Then choose fix my computer
    -Then Toshiba HDD Recovery.

    This should allow you to start the Toshiba HDD recovery process.

  • Satellite A110-277: can not access the internet wireless

    Hello
    I have a Toshiba Satellite A110-277. We have wireless internet access in our House and it was workin fine, but since a few days I can not access the internet. My laptop is certainly recognizing internet connection wireless, but through IE or Firefox it just does not connect.

    For some reason, he worked briefly through Firefox, but then that stopped. I don't see what anyone, I have done differently, other than (finally) updated Windows Media Player, but why would that cause problems, I don't know!

    I would really appreciate help as soon as POSSIBLE, that the internet is my lifeline to work!
    Thank you
    GcDh

    Hello

    You said
    > My laptop is no doubt recognize the wireless internet, but does not connect via IE or Firefox, it's just
    Hmm, I guess that you can connect to the WLan router and can insert the WiFi encryption key successfully right I'm right?

    How does LAN connection? Can connect you to the internet using the LAN cable?

    Feedback would be appreciated

  • I am able to access my desktop to my laptop as part of a homegroup, but can not access the external hard drive that is attached to my office.

    share external hard drive

    I am able to access my desktop to my laptop as part of a homegroup, but can not access the external hard drive that is attached to my office. I want to be able to back up my laptop hard disk external.  Advice please.

    geraintjo

    I do not use homegroups, but 'true' to share, so I don't know how this is supposed to work with homegroups. But usually he should share a drive or folder, first before you can access it from another machine. (for example, click on the drive/folder properties and go to the sharing tab)

  • Can not access the updates XP, 0x8024400A error message.

    I reformatted my HARD drive, reloaded XP SP2 Home. Download IE 8. I need XP SP 3, but now I can not access the updates... 0x8024400A error message.

    Help please

    Hello

    Install SP3 by downloading and running from...

    http://www.Microsoft.com/download/en/details.aspx?displaylang=en&ID=24

    You can ignore the text that says it's for network installations and also ignore the text advising windows/microsoft update if a single update of a PC.

    This should move your 0x8024400A problem. So try and get up-to-date with the Windows updates. You will probably have to go through Genuine Windows Validation.

    Tricky

  • My desktop computer shows that it is connected to the network. However I can not access the detained.

    without intwernet access network connection.

    My desktop computer shows that it is connected to the network. However I can not access the detained. Other computers using the wireless modem work fine. I'm NOT computer savvy, so I am at a loss. I ping tri3ed myself and the result is unanswered.

    Hello

    You can consult the following thread link and check.

    PING: transmit failed, error code 5.

    Important: The above link contains steps that tell you how to modify the registry. However, serious problems can occur if you modify the registry incorrectly. Therefore, make sure that you proceed with caution. For added protection, back up the registry before you edit it. Then you can restore the registry if a problem occurs.

    For more information about how to back up and restore the registry, follow the steps from the link below:

    Back up the registry

  • Computer shows as connected... but we can not access the internet.

    Original title: but alas... internet no.

    Recently, we had this problem where our shows as connected pc... but we can not access the internet.  What I've been able to solve, is that somehow my IP settings change.

    I'm going to "Obtain an IP address automatically" and "Obtain DNS server address automatically", but of course... when the problem occurs again I find that my "Obtain DNS server automatically an address" has been changed to "use the following DNS server address".

    What is causing my computer to change my settings?

    I think you're DIY too.  Normally, your computer and your wireless router assign dynamic IP addresses, and they change periodically - that is part of the security design.

    In your case, the DNS server is the router.

    Most of the time what you describe is your computer is able to find a wireless router but the router doesn't send an IP (its normal function).

    This is usually:

    1. Your Internet service provider is down or your connection to it is broken.  If this is the case there is nothing you can do about it.
    2. Your computer network security key does not match the one in the router.

    1 reset the modem & router.  Follow these instructions precisely: http://canadiantech.info/?page_id=136

    2. If that does not resolve the problem, you must remove this network from your list of networks to manage Windows 7.  Then try to connect again using the network key, you know.

    3. If this does not work, you will need to do a factory reset on the router and re - install the router according to the router set up instructions.

    4. If after all the above does not correct the problem, you must replace your router.

  • When a user logs off Windows 7 x 64 session, the rest can not access the internet until the restart network card

    Hello! I found a problem with my system: when a user logs off Windows 7 x 64 session, the rest can not access the internet, until restarted network card. Reinstall NIC driver did not help. Problem appears on a built-in adapter, in the motherboard and a separate PCI card too.  Same router via its web interface is not accessible. Windows cannot automatically fix this problem after trying to diagnose a problem with his problem Diagnostic tool. After the diagnosis in the DETAILS window, MORE tests, it displays a message like this "computer remote can not receive a connection via the Internet (HTTP) Service Port". "Unplugging" a corresponding Local network connection and then reconnect solves the problem immediately. Switching between users, when two of them are connected do not cause this problem. Important: the problem occurs in the account of the user who was logged on the system FIRST after the PC was on, when the user disconnected on newspapers of a SECOND. If the SECOND user is logged in and the FIRST user disconnects, SECOND can still access the internet. It depends only on the sequence of the user's record, not on the particular user name. And one more interesting fact: after each user registered on and outside just for once, the problem seems to disappear until the PC is turned off and turn it back on!

    System details:

    Motherboard: ASUS P8Z77-VLK
    CPU: Intel Core i7 3770 K
    RAM: 8 GB
    OS: Windows 7 x 64

    Hi, Mahesh,

    and thank you very much for your help! Update firmware driver and router LAN did not help me get rid of my problem, but greatly improved my experience of networking in general. Anti-virus software was not guilty, also, but! I found the "iControl" network software, installed as part of Sogiciel 'AI Suite II' (that came on the CD of motherboard ASUS driverssoftware), runnning and causing not only the problem mentioned above, but would also decrease upload speed up to 0.3 MB/s, when download passes to nearly 100 Mbps! Moreover, searching the Internet, I have found a lot of complaints about the behavior of this software, so that people watch you the occasional installation of this piece... sweet ;) As "iControl network" has been uninstalled (not only turned off in the settings of 'Ai Suite II'!), I'm totally happy with my system performance.

    Best regards
    Greg

  • Can not access the rows of an item of table no-netsed in execution of the embedded R

    Hi all

    I am running a script R (R running embedded) oracle database

    I use under request

    Select *.
    table (rqEval (cursor (select 'divider' 50, 500 "numDots" of the double),))
    "select 1 id, 1 double val,"
    'myRandomRedDots2'));


    I want to save the result in a variable. So under anonymous block has written


    declare

    ID number (10);

    Val number (10);

    Start

    SELECT id, val in id, val

    table (rqEval (cursor (select 'divider' 50, 500 "numDots" of the double),))

    "select 1 id, 1 double val,"

    'myRandomRedDots2'));

    end;

    /

    But I get the error "can not access an element of no nested table lines.

    The one you suggest please how to fix this.

    Thank you

    Billa


    Billa,.

    You see the error "can not access the lines of a no nested table element" of PL/SQL, because rqEval (..., ' select 1 id, 1 double val ',')

  • I have a cc has photoshop &amp; lightroom, but can not access the mobile app for my ipad, I get a free 30-day trial?

    I have a cc has photoshop & lightroom, but can not access the mobile app for my ipad, I get a free 30-day trial?

    Hi Michael,

    Please try the below mentioned steps to activate Mobile with Lightroom.

    Thank you

    Atul Saini

  • I'm trying to upgrade a site from Muse and it keeps telling me that the site has been created with a different version of Muse. I have updated Muse and still can not access the site to make changes.

    I'm trying to upgrade a site from Muse and it keeps telling me that the site has been created with a different version of Muse. I have updated Muse and still can not access the site to make changes.

    Hi rgarden95,

    Can you please confirm the exact version of Muse, you open the file with?

    To check the version of Muse, please click Help-> on Adobe Muse CC.

    Kind regards

    Akshay

  • Error: 303: unable to load a resource: can not access the resource file (try loosening Flash security)

    Error: 303: unable to load a resource: can not access the resource file (try loosening the Flash security settings): error #204 in shockshare.com and putlocker.com any help please?

    When I was watching a movie... There was a link, I always watched movie shockashre and putlocker.com but today, I saw this problem and don't kno how to solve

Maybe you are looking for

  • HP Pavilion 15 laptop: Short hard drive DST check failure... once again.

    A question that I had resolved a few months ago started occurring again, in which the laptop is struggling to load things when started and soon after falls down and has to be restarted. I guess that means that the hard drive has failed once again and

  • Hard drive erase: leaving of Instructions for survivors

    What could be the easiest instructions possible to leave my wife super-non-technical on how to erase the hard drive of my iMac? Medical diagnostics convince me I want to be better prepared that I was so far for all requirements.

  • Advice from rMBP to Mac Mini

    Hello Looking for reviews, I hope other people who have some experience. I will try to keep things simple. I am a photographer who bought a 2104 13.3 "rMBP refurbished Apple 5 months ago. It was a nice affair. Although I realize that I'm not happy wi

  • APPLICATION SOFTWARE PROBLEM - HP DV6 ENVY

    Help me pleaseMy Hp Dv6 envy, after downgrade to windows 7, whenever I have install most software, they later stop aperture, reducing the complete function or just stop working. I want you to help me please am a student. I thank very you much.

  • Can TestStand create a new database

    I have what I thought, it was a simple question, but I can't find the solution. When you use the data logging choose us what file it is written (I use Access). I was wondering if there is a way to have TestStand automatically create and save a new fi