Connection signal of C++ with slot QML

Before ask you, I searched for answers to this question, but I have not found a satisfactory example.

I have set up a service network in C++ that performs queries to REST against a backend. An example query would be to download a given element, the id of the item.

Once the item is extracted, I emit a signal such as:

itemReceived(QString& itemId, QString& item);

My question is how can I wire this signal to the slot in a QML page so that the status of the answer? I tried to connect the signal on the Qml in C++ slot, as follows:

QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
QObject::connect(this->networkingService,
                     SIGNAL(itemReceived(QString&, QString&)),
                     qml, SLOT(onItemReceived(QString&, QString&));

With a correspondent QML "slot" like this:

    function onItemReceived(x, y) {
        console.log("*********************");
        console.log("Item Received!");
        console.log("*********************");
    }

But it does not work. I also tried using the element of connection of the QtQuick lib, but this also fails.

Any help would be greatly appreciated. Even if he were to propose a better architecture for the "path of the cascades. Thank you!

In C++:
QmlDocument * qml = QmlDocument::create("asset:///main.qml").parent(this);
QML-> setContextProperty ("_app", this);

In QML:
{Page}
onCreationCompleted: {}
_APP.itemReceived.connect (onItemReceived)
}

function onItemReceived (x, y) {}
Console.log("***");
Console.log ("point received!");
Console.log("***");
}

// ...
}

Tags: BlackBerry Developers

Similar Questions

  • How to connect the signal of C++ with slot QML?

    {Of connections

    target: Foo //object in c ++ side

    onMySignal: {/ / slot in qml side}

    ......

    }

    }

    It can connect mySignal of Foo in C++ with slot onMySignal in QML.

    Is there some replacement for above cascading?

    Please use the forum search before posting new questions.  In this case you would probably find this thread, at least: http://supportforums.blackberry.com/t5/Cascades-Development/QML-Connections-Element/m-p/1787071#M664

  • Connection of signals in C++ with slot in QML

    In my app.cpp class

    (1) I said a signal named 'activityStopSignal '.

    (2) in this class that I charge a qml file

    Here's my class c ++

    #ifndef ApplicationUI_HPP_
    #define ApplicationUI_HPP_
    #include 
    #include
    #include 
    
    #include 
    #include 
    #include 
    
    using namespace bb::data;
    using namespace bb::cascades;
    
    namespace bb
        {
            namespace cascades
                {
                    class Application;
                    class SqlConnection;
                    class ListView;
                }
        }
    
    class ApplicationUI : public QObject
    {
        Q_OBJECT
    public:
        ApplicationUI(bb::cascades::Application *app);
        virtual ~ApplicationUI() {}
    
       signals :
            void activityStopSignal(); ///here I have defined the signal
    
    private slots:
       void replyFinished(QNetworkReply* netReply);
    
    private:
        void Initialise();
        bb::data::SqlConnection* m_sqlConnection;
        bb::cascades::AbstractPane *rootLoginEng;
    };
    
    #endif /* ApplicationUI_HPP_ */
    

    In this qml file

    (1) I set the location for the signal "activityStopSignal".

    (2) I gave the link with the signal and slot

    Here is my qml file

    import bb.cascades 1.0
    
    Page {
        Container {
            layout: DockLayout {
    
            }
    
            Container {
                layout: DockLayout {
    
                }
                ImageView {
                    imageSource: "asset:///images/logo.png"
                }
            }
            ActivityIndicator {
                id: activity
            }
    
        }
    
        onCreationCompleted:
        {
            activity.start();
            _myClass.activityStopSignal.connect(activityDone) //here i have given the connection to the signal
    
        }
    
        function activityDone() {
            activity.stop();
            _myClass.loadHomePage();
        }
    
    }
    

    Now my problem is:

    When I try to call 'make activityStopSignal' the application crashes. Where Iam wrong please help me

    Here is the app.cpp file where Ian trying to broadcast the signal

    // Default empty project template
    #include "applicationui.hpp"
    #include 
    #include 
    #include 
    #include 
    
    using namespace bb::cascades;
    using namespace bb::system;
    using namespace bb::data;
    
    ApplicationUI::ApplicationUI(bb::cascades::Application *app)
    : QObject(app)
    {
          Initialise();
          QmlDocument *qml = QmlDocument::create("asset:///splashScreen.qml").parent(this);
          qml->setContextProperty("_myClass", this);
          AbstractPane *root = qml->createRootObject();
          app->setScene(root);
    
          postJsonRequests();
          emit activityStopSignal(); //here I emit the signal
    }
    

    Someone help me please

    the connection of the signal seems ok, I would say you delete the code in your function and use a simple console.log to see if she is called correctly.

    If you want to process the request json first before emitting the signal you should check your code, networking is async your postJsonRequest will probably return before the end of networking.

  • Satellite A500 - 15 M: unable to connect to the TV with HDMI

    Hello

    I have a Satellite A500 - 15M. I recently tried to connect to my TV so I could watch certain shows online on my Hannspree Xv HD ready TV.
    The HDMI out does any record on the TV - the TV displays a message "not supported" and remains off (as if there is no signal) - display settings on the PC it does not recognize the TV... actually it [Intel Graphics and Media Control Panel] indicates that the TV/monitor settings are not supported.

    But I can connect via the VGA output - although I have to delete the display settings to 1024 x 768 to show on TV. In addition the display on the TV then is mainly pink and red, even if my pc display peak is most often blue. -start of the Toshiba screen displays on the TV, without any problems and one or twice the login screen was displayed too much, but then sometimes it isn't...
    I know that's not the VGA cable as I can connect to the TV with it on netbook advent my wife without any problem.
    Are there drivers, I need to update / download? Or I need to change the settings?
    How can I get my screen on my TV?

    Any help would be greatly appreciated. Thank you

    Hello

    First, you must connect the two machines (laptop and TV via HDMI) when the two devices are turned off. After turn on the TV and the laptop.

    You must choose the HDMI on TV channel and should then use the FN + F5 key combination to switch the video output to the TV.

    If this does not help, try updating the graphics card driver.
    It seems that your laptop supports the Intel graphics chip. Therefore, you can see the Intel page for new drivers.

    Welcome them

  • My ZTE open C unable to connect to the wlan with 63-signs-hex key.

    Hello

    my C open from ZTE unable to connect to the wlan with WPA2-PSK and a 63 sign hex key. When I create a 2. ESSID with WPA2-PSK a sentence normal, everything's fine.

    Oliver

    Hi OliverwithZTE,

    I understand that you have connection problems to your network WPA2-PSK.

    Unfortunately, WPA2-PSK is currently not supported on Firefox OS version 1.3. Only WPA-TKIP and WPA2-AES are supported.

    -Ralph

  • Unable to connect to the internet with Foxfire. Can do with Internet Exporer

    I've been using Foxfire. After an update I can no longer connect to the internet with Foxfire. IE can connect.

    Firefox is the name. Foxfire is a bio-luminescent fungus.

    http://en.Wikipedia.org/wiki/Foxfire _ (bioluminescence)

    See this support article - difficulty of problems connecting to websites after Firefox update

  • How to connect a Toshiba TL838 with facebook profile?

    How to connect a Toshiba TL838 with facebook profile?
    When I try to connect toshiba generate email with info and links for connect facebook with toshiba accounts places but when I click on the links I see only errors.

    _ * EDIT * _

    * Ok I flashed the QR code with my phone and now is connect :) *.

    Moderators please close thead

    Post edited by: junioreks

    > Ok I have flashed the QR code with my phone and connect now :)

    Thanks for sharing!

  • Tecra M3 has ceased to connect to the internet with cable

    I have an old laptop Tecra of 3 year (out of warranty).
    Last week, he stopped to connect to the internet with a cable. I tried several cables and jacks. No idea what to do?

    LAN card is entered correctly in the Device Manager?
    LAN port has two leds, green and orange. Green LED is turned on when you connect the LAN cable?

  • Can I connect an iPad pro with a mouse logitech M535?

    Can I connect an iPad pro with a mouse logitech M535?

    N °

    NO mouse will work on iOS and Apple iDevices.

    There is no pointer/cursor physical programmed in iOS for the mouse navigate on the screen.

    Your fingers are your the mouse input device.

    iOS has an 'I' slider which can now controlled insertion point by invoking the keyboard of the iOS of beam software and then do a single tap with two fingers to tirn software keyboard together area in a giant trackpad.

    If you useb double two fingers type in keyboard area, you can put it into words, lines of text or paragraphs for editing.

  • I am trying to connect a Macbook Pro with Retina display for a new monitor Dell Ultrasharp 3014. I tried to connect via HDMI and DVI cable supplied with the monitor but the monitor says "no cable dvi - d".

    How to connect a Macbook Pro with the (just bought) Retina display for a Dell Ultrasharp U3014's new? I tried to connect with HDMI and DVI cable supplied with the monitor but the monitor says "no dvi - d" cable. I never tried to do that before so I'm lost.

    Use a mini-displayport cable. Connect to one of the ports Thunderbolt the MacBook Pro to ultra-compact monitor entry.

  • The Apple Magic Keyboard can operate without bluetooth when connected to an iPad with the lightning to the USB camera adapter?

    The Apple Magic Keyboard can operate without bluetooth when connected to an iPad with the lightning to the USB camera adapter?

    I love the Apple Magic Keyboard to be very light (I want it with me everywhere). I also like that I can choose the layout of the keyboard I want (Canadian multilingual), which is not available on any keyboard for any brand, with the exception of Apple iPad (and I did a ton of research). I have problems with the old model of keyboard Apple Wireless because of the Bluetooth connection: I often have trouble connecting. I want a reliable keyboard. I don't like having to plug the keyboard on the iPad, and I think that a wired keyboard can more reliable and safer than a wireless keyboard. And a wired keyboard never had battery problems.

    I read that the Apple Magic Keyboard can work wired with a Mac without bluetooth. And I read that some USB keyboards work with lightning to the USB camera adapter. There are several keyboards with a cable (Belkin or Logitech) lightning, but none with the available Canadian multilingual.

    So, if I buy a magical keyboard Apple and a Flash to the USB adapter of the camera, according to my needs, I'll be satisfied or I'm going to be disappointed?

    A better solution would be to have a male-male cable lightning between the keyboard and the iPad, but I don't find any of these products anywhere.

    Thank you.

    It will not work. And where did you read that the keyboard works wired with a Mac?

  • connect labveiw 8.2 with nor pci-6251

    I have no pci-6251 and its cd driver with labview 8. How can I connect the daq with labview 8.2 and run programs

    Hello

    I can't download the driver of NOR-DAQmx 8.7.1, connect labview 8.2 with NOR-DAQmx PCI-6251...

    Why?

    Please answer...

  • I put my cRIO 'DHCP' to 'local connection' and lost contact with her.

    I put my cRIO 'DHCP' to 'local connection' and lost contact with her.

    I changed the location setting labelled '2' to post a link-local only, so I think I hit save to '3 '.  So, I have had no contact with my cRIO network.

    I tried;

    Hit the reset button

    A MAX of opening closure

    Go to safe mode

    Lift the switch to reset IP

    Power cycling the cRIO

    Directly from the host to my target of cat 5 cable running

    None of it worked, and I have no contact with my cRIO.

    This is what MAX looks like now.  How can I fix?

    It turns out that I had more of a problem.  Corrupt drivers, 255 in many in my subnet mask, overly complex LAN, use server control... you get the idea.  So I just deleted all software, disassembled everything and more from scratch.  Now back to the top and work.

    Thanks for the tips everyone, all the pieces and peace where it is useful to help me see the bigger picture.

  • Connection ethernet or GPIB with Keithley 2612

    Hallo

    Here's my situation:

    I'm relatively new to LabVIEW programming and want to install a configuration of measurement with LabVIEW and a SMU double Keithley 2612.

    If I m work myself through Labview Beginners Guides and how to connect a measuring device with the first simple LabVIEW program.

    Since I Don t own a GPIB-USB adapter for the moment, I was thinking of using Ethernet for the EMS connection that gets ist own IP address. The connection to the PC works and SMU SMU ethernet can be remote controlled.

    Here's my problem:

    I can´t find (usable) guides for the installation of LabView via Ethernet.

    My 500 pages book 'Introduction to LabVIEW' (as of 2009) doesn´t have even a hint for an ethernet connection, while the GPIB, RS232 and CAN are covered pretty well.

    Here's my question:

    Should I continue to try to get LabVIEW working on Ethernet, or would it be better to buy a new adapter USB GPIB.

    Does anyone know good Howto for creating Ethernet connections?

    Should I just the bad 'Introduction to Labview?

    The use of Ethernet has disadvantages compared to the GPIB-USB?

    I'm happy to answer additional questions.

    Thank you.

    Download the Labview driver for the series of 26xxA from Keithley web site.

    For a Visa resource string use something of the form: "tcpip::aaa.bbb .ccc. ddd::instr" where aaa.bbb.ccc.ddd is the ip address of the instrument that you can get through the façade or run MAX and auto-le discover.

    When you finally get a USB-GPIB converter all you have to do is change the resource in the form of gpib string: GPIB::XX:instr «»

  • while I connect to my computer with the samsung wave y kies wi - fi computer displays an error as a peripheral denied connection permission, please provide the solution.

    while I connect to my computer with the samsung wave y kies wi - fi computer displays an error as a peripheral denied connection permission, please provide the solution.

    earlier, I used internet and transfer files through this link, but now it is showing the device refused permission. I have checked all the settings, but could not remedy any problem so kindly help me so that I can connect via wifi to my mobile samsung kies.

    Also, I am facing problem in sending files via Bluetooth, and at the same time my mobile can easily transfer the file and the music file actions with my computer via bluetooth which I did not understand.

    Rental offer the solution to both problems. In my computer I have window7 profeessional.

    Marie-Odile THE

    Hello

    1. What is the brand and model of the computer?

    2 have you made any changes to the computer before the show?

    Reinstalling the Kies application and check if it helps.

    See this link:

    http://Windows.Microsoft.com/en-us/Windows7/uninstall-or-change-a-program

    I also suggest you to contact Samsung and check: http://www.samsung.com/us/support/

    Regarding Bluetooth check out these links:

    Open the hardware and devices Troubleshooter
    http://Windows.Microsoft.com/en-us/Windows7/open-the-hardware-and-devices-Troubleshooter

    Bluetooth devices do not work correctly on a computer that is running Windows 7:

    http://support.Microsoft.com/kb/980396

    Also see this link: http://Windows.Microsoft.com/en-us/Windows-Vista/troubleshoot-problems-with-Bluetooth-enabled-devices

    Note: The article mentioned above is also applicable to Windows 7.

    I hope this helps!

Maybe you are looking for

  • How can I change the base station Airport of NAT mode?

    I'm trying to set up an Airport base station and stuck because I have the following message is displayed, but no idea how do what he asks... Status is showing as Double NAT and then asking me to move on to the base station in bridge DHCP/NAT mode. Bu

  • Get rid of the 'Unsorted Bookmarks' in FF 30

    30 FF is apparently hard-coded. "Unsorted Bookmarks" is now at the end of my well sorted list. I want to get rid of, permanently delete, kick on the sidewalk. It's the kind of ugly with this thing hanging out there. I'm using Linux Mint Debian Editio

  • Message update apps - problem

    I had the 'Find My Friends' app for a few years. It's the first time that I have the following problem and the problem was the same consistenly for the past few weeks. In iTunes (Windows 10), Apps, updates, the referenced application icon appears. I

  • problem of change of name of the file in win xp sp3

    When I rename all the files in xp sp3, it cannot be a dialog box open box "If you change the file name extension would it be unuseble" what can I do

  • Hqas Internet Explorer modified this page to avoid scripts between sites.

    I have Internet Explorer 8. I have the Vista operating system. I get the above error message while trying to play a game on facebook. I only started getting this error until today. Windows has automatically downloaded an update this morning. The upda