Call the function QML from C++ (simple question)

I guess that's a pretty easy question but I'm a bit new apart from development c ++ of BB10. I have a QML file in the assets folder called Functions.qml which has only onne inside functions.

import bb.cascades 1.3

Page {
    objectName: "funct"
    function printStat() {
        console.log("hello");
    }
}

In one of the functions in applicationui.cpp there is a function called resendNotification() (you may know this code from the model of the app without head)

void ApplicationUI::resendNotification()
{
    InvokeRequest request;
    request.setTarget("com.example.TestNotificationService");
    request.setAction("com.example.TestNotificationService.RESET");
    m_invokeManager->invoke(request);    // --> call the printStat() function of Functions.qml file
    Application::instance()->minimize();
}

My question is, before you minimize the app How can I call the function printStat() of the qml file? I have always developed my apps in QML so never had to deal with c ++. Should be easy enough to call a function well.

Thank you in advance!

first step is to find the object by ObjectName using findChild, usually from your element root (navigationPane).
example:
NAV-> findChild ("myTextField")

If you have the object of another source that is fine too, of course.

second step is to use QMetaObject::invokeMethod with the object and the name of the method.
Example:
QMetaObject::invokeMethod (container, "setText", Q_ARG (QVariant, text));

Tags: BlackBerry Developers

Similar Questions

  • call the function onCreationCompleted c ++ in qml

    I currently have a problem with the c function call ++ QML.

    Œuvres of normal calls. But when I call a function in onCreationCompleted, he cannot access qml object on the page.

    For example:

    {Page}

    onCreationComplete:

    {myFunction() ;}

    Button {}

    ojbectName: "button1".

    }

    }

    MyFunc access using findChild button1.

    But this return 0 x 0, means the button does not exist.

    So how do I access button1 in c ++ to what page is loaded?

    I have posted from a phone, so sorry if there is no error.

    Look, we can't access the qml object when the page is created (we call it in onCreationCompleted). I bypassed by calling the function after navigationpane.push.

  • Call the function in LabView from a DLL, and then access the global variable of DLL

    I've created a DLL in LabWindows with a function and structure.  I want to call the function from LabView and then access the overall structure.  I am able to call the function in the DLL with a "call library function node" and has access to the return value, but I can't understand how to access the overall structure.  The structure is declared in the header DLL with __declspec (dllimport) struct parameters file.

    Is it possible to access this structure without using the library of network variables?

    My guess is that you need two bytes of padding after "in_out" and another to two bytes of padding after "anin."  The reason being that ints are 4 bytes, and most of them C compilers will align on 4-byte boundaries.  The struct will naturally start to such a limit (in fact, in Windows, it will probably start to an 8 byte boundary).  If you then count bytes in your structure, you are 70 byte after "in_out."  70 is not divisible by 4, so you need 2 bytes more to reach the next 4 byte boundary.  You can also you could reorganize your struct so that "anin" follows "in_out" and this is probably the best option if it won't cause you other problems.

    Unlike most C compilers, LabVIEW compressed structures as closely as possible, without filling.  I don't know enough about the history of LabVIEW and internal parts to explain the reasons and to do this performance penalty, but, as choice of LabVIEW "endianness", it is probably a remnant of the first versions of LabVIEW that were running on the Mac.

    If for some reason you want to force your C struct to match package LabVIEW, you can use the #pragma pack (x) directive, but I wouldn't recommend that here because you can control the C and LabVIEW.

    EDIT: in the cases where it was not clear, add padding to your cluster of LabVIEW, insert appropriate size or items at the place desired in the cluster.

  • Can headless part of the application calls a function QML?

    Normally, when you write code in c ++ in the part of the user interface of the code, I am able to call the function of any file QML by writing the code below.

    QmlDocument *qmldoc = QmlDocument::create("asset:///Functions.qml");
    AbstractPane *root = qmldoc->createRootObject();
    QMetaObject::invokeMethod(root, "printResult");
    

    In headless of demand, I create another qml file, called "NotificationHandler.qml" in the current folder of the game without head. In one of the file c ++ without head when I write the same thing, it gives an error indicating that

    C:/bbndk/target_10_3_0_698/qnx6/usr/include/bb/cascades/resources/qmldocument.h:366: undefined reference to `bb::cascades::QmlDocument::QmlDocument(QUrl const&)'
    

    Below, you will find all the code inside the service.cpp which is the game file without the application head.

    #include "service.hpp"
    
    #include 
    #include 
    #include 
    #include 
    #include 
    #include 
    
    #include 
    
    using namespace bb::cascades;
    using namespace bb::platform;
    using namespace bb::system;
    
    Service::Service() :
            QObject(),
            m_notify(new Notification(this)),
            m_invokeManager(new InvokeManager(this))
    {
        m_invokeManager->connect(m_invokeManager, SIGNAL(invoked(const bb::system::InvokeRequest&)),
                this, SLOT(handleInvoke(const bb::system::InvokeRequest&)));
    
        NotificationDefaultApplicationSettings settings;
        settings.setPreview(NotificationPriorityPolicy::Allow);
        settings.apply();
    
        m_notify->setTitle("NotificationWork Service");
        m_notify->setBody("NotificationWork service requires attention");
    
        bb::system::InvokeRequest request;
        request.setTarget("com.example.NotificationWork");
        request.setAction("bb.action.START");
        m_notify->setInvokeRequest(request);
    
        onTimeout();
    }
    
    void Service::handleInvoke(const bb::system::InvokeRequest & request)
    {
        if (request.action().compare("com.example.NotificationWorkService.RESET") == 0) {
            triggerNotification();
        }
    }
    
    void Service::triggerNotification()
    {
        qDebug() << "first";
    
        QmlDocument *qmldoc = QmlDocument::create("asset:///NotificationHandler.qml");
        AbstractPane *root = qmldoc->createRootObject();
        QMetaObject::invokeMethod(root, "startNotificationService");
    
        qDebug() << "second";
        // Timeout is to give time for UI to minimize
        // QTimer::singleShot(2000, this, SLOT(onTimeout()));
    }
    
    void Service::onTimeout()
    {
        Notification::clearEffectsForAll();
        Notification::deleteAllFromInbox();
        m_notify->notify();
    }
    

    I use the same logic, but apparently it is forbidden to treat the QML files in without the request or I have made a serious mistake. Could you please help?

    I thank very you much.

    usually the part without head does not reference libraries of stunts because they have a serious memory footprint.
    The part without being limited in memory head, which gives it its own UI isn't usually a good idea.

  • How to identify which switch in the Panel called the function?

    Here I have some 192 switches and 192 leds corresponding to each switch,

    If a switch is on(say 10th) consequence (10th) led should light up.

    I want to use the same function for all pairs of led switch.

    all I could do was to check the switch in a loop and then set the individual leads, but I find it very little effective way to do it.

    int switchOnOff (int, int int event control panel CVICALLBACK,
    void * callbackData, int eventData1, int eventData2) is the function.

    None of these arguments I can use it to extract what (the unique id for this turnout) switch called the function so that I can pass corresponding led glow?

    It occurred to me now that the table is not necessary at all: you can simply assign to each switch the corresponding ID led the callbackData, so that the code is even simpler than my previous:

    // At panel load:
    SetCtrlAttribute (panelHandle, PANEL_SWITCH1, ATTR_CALLBACK_DATA, (void *)PANEL_LED1);
    ...
    SetCtrlAttribute (panelHandle, PANEL_SWITCH192, ATTR_CALLBACK_DATA, (void *)PANEL_LED192);
    
    // In the control callback
    GetCtrlVal (panel, control, &sts);
    SetCtrlVal (panel, (int)callbackData, sts);
    

    To answer your last question, "Management Board" means immediately after the call to LoadPanel.

  • MuseJSAssert: Error calling the function switch: TypeError: undefined is not a function (assessment '$element .on this.')

    As usual I never update muse immediately incase of any question, however, a few days after the update (have not installed the update) I go on my site, this message appear out of no where "MuseJSAssert: error calling the function switch: TypeError: undefined is not a function (assessment ' this.)" ($element.sur ') ".

    So I decided to install the update and see, but the message would have still done appear then I wiped my server and download all my files to perhaps solve the problem of Javascript, and yet the message is still displayed.

    Note that this came from nowhere even tho I don't update my muse or uploaded to my FTP in days.

    My site entire is now totally useless after months in manufacturing.

    Can anyone help?

    The error on the sites is caused by having custom include the code that loads several different versions of jQuery. A single Web page should only have one.

    The redirect URL that fails intermittently. We actively work to diagnose and fix that, but which will not only cause these errors. Each Muse site contains a snippet of JavaScript that silently and automatically returns to use the version of jQuery that muse will be mailed to your host if the CA version is not available for some reason any.

    The problem is a number of customer sites have wrong incorporated several different versions of jQuery. When the CDN version is available, it is used. Unfortunately, when it is not available, an incompatible version loaded by the custom code or third-party widget is used and which translates these errors.

    Long term loading multiple versions of jQuery should be removed from the code or the third-party widgets on your site. In the short term, we will have solved CDN failure and these errors will disappear, but they return in the future if multiple copies of jQuery in the code no Adobe added to the page are not deleted.

  • Transfer while calling the function of a trigger

    Hello

    I would appreciate if someone can point me in the right direction. So I have a trigger (TableAR_BU) on a table table. This trigger, I have a logic to call the function, and inside this function, I'm just a select statement of a few other tables that the table table.
    Function is supposed to return me 'Y' and it done correctly returns me 'Y' if I select the double feature. -Select the Function1 (100) twice;

    But when I call the trigger function, it returns me 'n'. So after investigation, I found that the select statement (selection of table) inside the function returns NULL when called from trigger.
     
    DROP TRIGGER TableAR_BU;
    
    CREATE OR REPLACE TRIGGER TableAR_BU
    BEFORE UPDATE
    ON TableAR_BU REFERENCING NEW AS NEW OLD AS OLD
    FOR EACH ROW
    declare
     localcontext varchar2(32000) := '; Context : ';
     sqlstmt varchar2 (2000);
    
     Status varchar2(1);
    
    Status := Function1(:new.Id);
    
    
    End;
    /
    
    
    function Function1(al_Id in TableAR.Id%type)
    RETURN  varchar2 is
    
    lsItemId TableAR.itemId%type;
    
    Begin
    
    Select itemId into lsItemId
    from TableAR
    where id = al_Id;
    
    
    
    Exception
    
    End Function1;
    Suggestions or comments appreciated.

    Edited by: Eclipse01 may 1, 2012 11:29

    The problem is that a level trigger line on table cannot query table or whatever it is that questions table call. In the middle of a SQL statement, the table is potentially in an invalid intermediate state if Oracle cannot guarantee that queries on the table return consistent or reasonable results so it does not allow queries of this type.

    99 + % of the time, it's a good thing because it means that you are trying to use triggers for something they are not designed for (in addition to creating applications that are terribly difficult to manage because an action like update a line will eventually create a huge cascade of effects). Most of the time, you are much better to reconsider the architecture and the displacement of the function call out of the trigger and in a sort of API that wraps the UPDATE statement (that is a stored procedure that made the UPDATE and calls the procedure).

    In the <1% of="" the="" cases="" where="" you=""> really want to do in a trigger, you would need a combination of objects (or a trigger composed containing several sections in 11 g). You would need
    -A package with a collection of table primary keys
    -A before the declaration that clears this collection
    -A level trigger line which inserts the: new. ID in the collection
    -A trigger statement that iterates over the collection and calls the function after.

    That, however, is a lot of moving parts to deal with, so it dramatically increases the complexity. If you only want to consider if you are really convinced that you must use triggers in the first place.

    Justin

  • Call the function in the UI part without head

    I develop some app with no head.

    When I change the code in the head part and build - launch. But nothing changes in the part without a head.

    I have another solution call the function in the UI part headless. But whatever it is called.

    Please help me solution?

    The part without head of a long walk without head application is still running in the background. It will not update until you stop the part without a head.

    To stop the game without leading the race, you have three choices:
    (1) build increment in the bar file version - descriptor.xml. This will force the part without head to stop and restart with the new code.

    (2) use the monitor of the device to manually stop your application from running. Then, new launch and your game without head will run the new code.

    3) to implement your own way without a head, like a button that would send a personalized call to headless with (say) action "com.myDomain.myAppName.SHUTDOWN" and when headless receive this invocation, operate you this line:
    BB::application::instance()-> quit()
    This will make the part without head stop, then you run and your part without head will take place the new code.

    I prefer the #3 method, but if you do, don't forget to hide this feature before releasing to the public.

  • MuseJSAssert: Error calling the function switch: TypeError: undefined is not an object (evaluation of "a.rules")

    I have this error on my Web site every time that I go. It disappears when I refresh three times.

    "MuseJSAssert: error calling the function switch: TypeError: undefined is not an object (evaluation of"a.rules").

    I downloaded the site with Filezila.

    Please help, what's wrong here?

    Thank you

    Hi Barbara,

    The question began to happen after you downloaded using the latest version of Muse?

    If so, can you try to remove the old files of the web server and re-upload using Muse?

    Kind regards

    Akshay

  • Get this error on pages MuseJSAssert: error calling the function switch: TypeError: $(...). museMenu is not a function. Have read and did what I could find to solve problems.

    Hi I keep getting the error MuseJSAssert: error calling the function switch: TypeError: $(...). museMenu is not a function on my Web site which is not published, but I am downloading in British Colombia through muse.

    I'm on a PC.

    I tried export to HTML and still have the same problems locally.

    I saw that someone had a problem with mailchimp forms in one of a previous post. I removed the a widget of external source? for reservation and it was always happening.

    I created a new project like this and downloaded BC site all the files again to see if she could make a difference but still have the error.

    It's my URL BCdraft - home

    I tried to look at the site in the section "console" (where you can see the code of pages) to see if I could see the error that people had already advised but I get nothing... maybe not completely published because?

    I have reloaded the site through the muse in British Colombia with "all files" and is always the same.

    Here are some pictures that can help...

    Once on the home page, it may come with the error immediately or not... If you choose to say the title of the FAQ

    choose faq.png

    You must then (or choose other titles until it is) have this error coming...

    error.png

    Note that the title you have previously chosen as 'FAQ' now as 'price '.

    Changes to old title pricing.png

    This title is for some time and seems strange appears again.

    Here is a picture of scripts/css in the admin of BC as I've seen that this can be a problem but I don't know if this is normal or not and how to fix...

    cpanel.png

    I had taken a break from building the site for about a month and I had added on changes, but not them uploaded to the server just left saved on my PC.

    In the hope of an easy solution; p

    See you soon,.

    Steve.

    I published BC... what I wanted to say is that I did not live.

    Export HTML was to check if the error occurred in the HTML files locally.

    It ended up being a code of the external widget that was causing the problem. With him removed the pages work fine. (I had removed what I thought of them while troubleshooting, but I forgot to a separate embedded image)

    Specifically, it is because it was a pop-up overlay widget made for reservations. When I put it to then start a new page in the tab it works now. Seems that muse has changed to something allowing overlays?

    My thanks to Neha in support

  • MuseJSAssert: Error calling the function switch: TypeError: cannot read property 'msie' undefined. Please help me in this.

    MuseJSAssert: Error calling the function switch: TypeError: cannot read property 'msie' undefined. Please help me in this.

    Hello

    Please check the following thread,

    Re: MuseJSAssert: error by calling the function of selection: [Object Error]

    Let me know if you have any question.

  • Error MESSAGE: MuseJSAssert: error calling the function switch: TypeError: a.on is not a function

    I get this error message on Chrome (see screenshot). A similar one on Safari (see screenshot). And what follows on Firefox:

    MuseJSAssert: Error calling the function switch: TypeError: $(...). registerBackgroundPositionScrollEffect is not a function

    The site is online here: http://www.flashbangfiction.com/

    I had something like this before and I fixed by removing the web cache etc. Now, nothing works to solve.

    Can anyone suggest a solution?

    Chrome Screen Grab.jpg

    Safari Screengrab.jpg

    Hello

    I just checked the site and I don't have the error. I use Google Chrome, Version 40.0.2214.111 m

    Let me know if you have any question.

  • That is producing this error: MuseJSAssert: error calling the function switch: Error: Invalid argument

    Website: http://lovehopemercy.org/

    In my navigation header by clicking on the option "VISIT US", that is to say generates this error: MuseJSAssert: error calling the function switch: error: invalid argument

    The other options do not work correctly. I get an error on export as HTML of MUSE, but the link works fine in other browsers. I download using Dreamweaver CC 2014. Reversal function works fine; it's the direct click of the menu item at the top that causes the problem.

    Did I miss a bad link or something that I can fix?

    Thanks in advance.

    Hello

    Could you please try some suggestions given here and see if it works for you.

    Error after update today: MuseJSAssert:Error call function argument: Error: Invalid selector

    Let me know if you have any question.

    Concerning

    Vivek

  • Is it possible to call the function Document disinfect since a JavaScript?

    Hi, I hope that this should be easy, but a link back are not the results of the research in the SDK from Adobe live. Is it possible to call the functions Document disinfect or remove hidden information of in a javascript script? Here pointers would be GREATLY appreciated.

    This command opens the dialog window Document disinfect, but you will still need to run it manually, and you will also need to run it from a context of trust.

    app.execMenuItem("DIGSIG:SanitizeDocument")

  • MuseJSAssert: Error calling the function switch: TypeError: $(...). toBrowserWidth is not a function

    Hey,.

    I made a site with Muse on April 2014 and now (September 2014) I got the latest version of Adobe Muse, updated the site, send to an external FTP client directly from Muse, and now my client told me that he cannot see the site of Mozilla Firefox from his PC. It is said that MuseJSAssert: error calling the function switch: TypeError: $(...). toBrowserWidth is not a function. He can see the site in Internet Explorer. And it works with my Firefox, Chrome and Safari browsers on mac.

    I have found some answers and tried: I added / of the museutils.js of the file so that it looks like this: {url:"/scripts/pie.js... and (" / MuseJSassert:... instead of: {url: "scripts/pie.js... and (' MuseJSassert:...") "}")}

    Done with the code in parentheses editor and send the files to a remote server with Filezilla.

    Now, it displays error on my browsers as well, he said: some of the files on the server may be missing or incorrect. After you click OK, the site seems normal.

    I also deleted the site distance and exported directly from Muse again. Now it looks fine on my browser again, but not customers.

    Any help?

    It's frustrating because I'm not a coder (I chose the Muse of reason) and now I don't know what to do...

    I checked out the site on my end, but can't reproduce the same error:

    http://take.Ms/dAPJ0

    Please try to delete browser cookies or try to reset the preferences.

    Thank you

    Sanjit

Maybe you are looking for