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.

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 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("***");
    }

    // ...
    }

  • Connection of signals ContactPicker

    Hello

    I can not connect the signal to a ContactPicker. Here is my code:

      ContactPicker *contactPicker = new ContactPicker();
      contactPicker->setMode(ContactSelectionMode::Multiple);
    
      bool success = QObject::connect(contactPicker,
           SIGNAL(contactsSelected(QList &)),
           this,
           SLOT(onContactsSelected(QList &)));
    
      if (success) { // Signal was successfully connected.
        contactPicker->open();
      } else { // Failed to connect to signal.
        alert(tr("Didn't connect the picker signal"));
      }
    

    I had similar problems when connecting the signal of a SystemPrompt, but I solved it by adding all the dependencies (in silence) in the hard drive file: I found an example of work and I saw everything what needs to be included. But for the ContactPicker, I can't find an example of work. Any help? Very much appreciated.

    Thank you.

    Hello

    const and & can be omitted, but they are not equal to a non-const reference.

    The following should work:

    Definition of slot:

    void onContactsSelected(const QList &contactIds);
    

    Connection:

    QObject::connect(picker, SIGNAL(contactsSelected(QList)),
                 this, SLOT(onContactsSelected(QList)));
    
  • Connect the signal to the PRC to slot QML

    Hi guys.,.

    Please help me with this

    I'm issuing a custom signal called imageLoaded of CPP that contains an image as a parameter. How can I connect this signal to a slot in QML and can access the image...?

    Thanks in advance...

    For example:

    import bb.cascades 1.0
    
    Page {
        id: myPage
        Container {
            layout: DockLayout {}
            Label {
                id: myLabel
                text: qsTr("Hello World")
                textStyle.base: SystemDefaults.TextStyles.BigText
                verticalAlignment: VerticalAlignment.Center
                horizontalAlignment: HorizontalAlignment.Center
            }
            Button {
                text: "Press me"
                onClicked: {
                    console.log("Boton clicked");
                    cppObject.imageLoaded.connect(onImageLoaded);
                    cppObject.executeCppFunction();
                }
    
            }
        }
    
        function onImageLoaded(message) {
            console.log("enter to slot in qml");
            myLabel.text = message;
        }
    }
    
    --------------------
    
    #ifndef ApplicationUI_HPP_
    #define ApplicationUI_HPP_
    
    #include 
    
    namespace bb { namespace cascades { class Application; }}
    
    class ApplicationUI : public QObject
    {
        Q_OBJECT
    public:
        ApplicationUI(bb::cascades::Application *app);
        virtual ~ApplicationUI() {}
    
        Q_INVOKABLE void executeCppFunction();
    
    signals:
        void imageLoaded(QString message);
    };
    
    #endif 
    
    #include "applicationui.hpp"
    
    #include 
    #include 
    #include 
    
    using namespace bb::cascades;
    
    ApplicationUI::ApplicationUI(bb::cascades::Application *app)
    : QObject(app)
    {
        QmlDocument *qml = QmlDocument::create("asset:///main.qml").parent(this);
    
        QmlDocument::defaultDeclarativeEngine()->rootContext()->setContextProperty("cppObject", this);
    
        AbstractPane *root = qml->createRootObject();
        app->setScene(root);
    
    }
    
    void ApplicationUI::executeCppFunction() {
        emit imageLoaded("Hello from C++ Signal");
    }
    
  • Connection of signals (with parameter) in QML.

    Hello

    I want to connect a signal (with parameter) in QML. I have the signal of my PPC and I am able to do that in QML, when I use signals that has no parameters.

    I want to connect to signals which takes the parameter.

    app.mySignal.connect (button.doSomething);

    I do not mySignal() issue, works very well.

    Want to do something like issue mySignal (int) and acess as QML in

    -Thank you

    your signal is:

    mysignal (QString)

    then connect to a function like that (qml)

    myClass.mysignal.connect (onmysignal)

    and:

    function onmysignal (mystring) {}

    Console.log ("my string is:" + mystring)

    }

    If you have several settings, you must be careful with the order and better to use descriptive names, as there is no type in the function definition.

  • connect multiple signals card NI USB-6341

    Hallo,

    I'm trying to connect the signals of several NI USB-6341 map.

    This map has 16 channels but not 32 pins available.

    for example if I want to connect a signal on channel 0 I connect to pins 1 and 2 and for channel 8, I have to connect to channels 2 and 3.

    If I connect only channels 0-7, it works but if I connect channel 8 I do not get the real value of this signal.

    any ideas?

    Thank you

    Theodore

    Theodore,

    This sounds like it should work.  Basically, you use AI0-3 and AI8 - 11 for your four differential signals.  This leaves you AI4 - 7 and AI12-15 free for single operation is complete.  The configuration of the terminal can be defined on each channel.  To do this, you can use DAQmx create channel several times to add channels with a different configuration to your task.  If you need details on it, let me know what environment you'll be programming, and I'll see if I can provide more specific assistance.

    Hope that helps,

    Dan

  • How can I get digital signals (interface UART) with a microcontroller with NI USB-6008?

    I have acauired a few analog signals by A/D (3 channels). I put each scanned data on 3 digital output with a microcontroller. I want to see if it is possible to import these digital outputs 3 to a PC via a USB-6008? It's like the connection of the output to the digital input of the USB-6008 and import the 3 channels simultaneously to LabView? Do I need to use some other hardware like USB-8451 and connect the clock of the MCU to USB-8451?

    Saraydin,

    The digital I/o on the USB-6008 is a software program only, so unless your signals are rather slow, it probably will not work for you.  In general, the procedure would be to connect each signal to one of the digital lines on the map and then set up a digital entry into LabVIEW task to read the three channels.  If you use a device that has clocked by the digital i/o hardware, you then your input clock signal and use it as the sample for the task clock.  Here is a list of USB devices supporting DIO clocked by the hardware.  Also, there is an example that comes with LabVIEW, which shows how to do this.  You can get to it in LabVIEW by going to help > find examples.  When the example Finder window opens, navigate to hardware input and output > DAQmx > digital measures > Cont read dig Chan-Ext Clk.vi.

    The 8451 is specifically for I2C and SPI, and would be great if you try to make one of these protocols, but otherwise I would recommend the devices in the list I linked above.

    -Christina

  • Unable to connect to a wireless network with Windows 7 computer laptop.

    After resetting my router netgear wireless home network, I have not been able to access my own network with my laptop. I already had access to the internet with a wireless ethernet cable and ankles bound to the router. After reset the netgear router, I was able to access the internet from two other laptops XP and an Acer mini wireless with no problems at all. But my new laptop Toshiba with Windows 7 could not connect, even if he could detect the network. I tried all day even resort to the ethernet socket and wireless cable, but even that would no longer work. I was able to connect using this same cable attached.

    Hello

    Seems that the Wireless does not work on the Dell.

    This is the process to try to find what wrong with it.

    ------------------

    Assuming that wireless router is configured correctly, it is a signal and the wireless card on the computer is physically in.

    Maybe this can help.

    These steps and tell us where is the breaking point.

    Check the Device Manager for the wireless card valid entry.

    http://www.ezlan.NET/Win7/net_dm.jpg

    If there is no valid entry, remove any entry from fake and re - install the drivers for the wireless card.

    Check network connections to make sure that you have a network icon/entry wireless connection, and that the properties of the icon (right-click on the icon) are correctly configured with the TCP/IPv4 protocol in the properties of network connections.

    http://www.ezlan.NET/Win7/net_connection_tcp.jpg

    ------------------

    The wireless card drivers much also install utility wireless of the seller.

    To ensure that if there is Wireless Utility a seller is not running with the native Windows wireless utility (Service WLAN).

    ----------------

    Make sure you firewall No. preventing / blocks wireless components to join the network.

    Some 3rd AV/Firewall/security software part, s costume keep blocking aspects of Local traffic even it they are off (disabled).

    If possible set up the firewall correctly, /Security costume otherwise totally uninstall and get rid of its remaining processes that permit the own local network traffic flow.

    If the 3rd party software is uninstalled, or disables, make sure Windows native firewall is active .

    party like Hello and NetMagic 3rd network managers can block local traffic too.

    ---------------------------

    Stack TCP/IP work should look like.

    Right-click on the wireless network connection card, select status, details and see if she got an IP address and the rest of the settings.

    http://www.ezlan.NET/Win7/status-NIC.jpg

    Description is the data of the card making.

    The physical address is MAC of the card number.

    The xx must be a number between 0 and 255 (all xx even number).

    YY should be between 0 and 255

    ZZ should be between 0 and 255 (zz all the same number.)

    The date of the lease must be valid at the present time.

    * Note 1. IP that starts with 169.xxx.xxx.xxx isn't valid functional IP.

    * Note 2. There could be an IPv6 entries too. However, they are not functional for Internet or LAN traffic. They are necessary for Win 7 homegroup special configuration.

    ---------------------------------------------------

    A message in the small window that says connected wireless doesn't means that you are really a valid functional connection.

    Above everything is OK, you must be able to connect to the router.

    Connection to the router means that you can enter the IP of the router base in an address bar in one go, being able to connect and configure the router menus see.

    If it doesn't connect to the router, journal newspaper from any computer that can connect to the router wirelessly with a wire, disable wireless security, make sure that the wireless SSID broadcast is enabled and try to connect with no. wireless security.

    Enable security wireless after you eat to make a functional connection.

    Jack-MVP Windows Networking. WWW.EZLAN.NET

  • When connecting two books of Mac with Migration Wizard using a cable Ethernet 'right' or 'twisted '?

    Hello

    Soon I'll have a new Mac Book Pro, and I would try Migration Wizard but > > > > when connecting two books of Mac with Migration Wizard should I use a cable Ethernet 'right' or 'twisted '?

    You can use either; There is no advantage to one or the other specific.

    (144276)

  • I just got a new modem (Arris SB6190) and now my Airport Extreme does not connect.  It worked fine with the previous modem (a rented one TWC).  Help!

    I just got a new modem (Arris SB6190) and now my Airport Extreme does not connect.  It worked fine with the previous modem (a rented one TWC).  Help!

    Always recommended to reset the airport back to settings by default and then set up again whenever you have a new modem or change your Internet Service provider.

    Turn off the new modem for at least 30 minutes. More is better.

    Perform a hard reset on the AirPort Extreme, then it turned off.

    Make sure that the Ethernet cable connects the modem to the "O" on the AirPort Extreme WAN port

    After the power of the modem 30 minutes down, turn on the modem and let it run for at least 5 minutes by itself.

    Then, turn on the airport and let it run a few minutes

    Set up AirPort Extreme again

    Important note... There are many reports of problems with the modem Arris SB and airports. Both are great products, but they do seem to work perfectly together for some users.

  • Unable to connect to SMTP using TLS with a certificate self-signed on OSX 10.10.1 (T31.3 & 24.6)

    I can't connect to my server SMTP with TLS on port (send 465 or 587 / 995 receive) using Thunderbird 31.3 or my OS X 10.10.1 24.6 (Didier) MacBook Pro.

    However, I am able to send and receive mail from the same account on my Windows 7 machine using Outlook 2007, using the same settings I configured in Thunderbird. I added the certificate etc.

    http://img.Photobucket.com/albums/v631/Napoleon_BlownApart/ScreenShot2014-12-16at121323pm.PNG (Taken when using 24.6)

    I am the admin of the server and the password and other settings on the side Server are correct! (I'll take a look at the evolution at the same time. I am already back to an earlier version of Firefox because of sloppy coding and broken features).

    Any ideas?

    If the server name is a secret, how you expect to receive mail. Please, we have pretty bad without guessing. Seriously what you are done using a self signed certificate, they are free by https://www.startssl.com/

    My guess is it of OSX who dislikes the self-signed certificate, how Thunderbird to deal with Windows. As you have a copy install Thunderbird and see if it is a question of OSX.

  • Can bookmarks be portable to multiple computers? Is it an option to connect and use my favorites with multiple computers and locations? Thank you

    Can bookmarks be portable to multiple computers? Is it an option to connect and use my favorites with multiple computers and locations? Thank you

    https://support.Mozilla.com/en-us/KB/what-Firefox-sync

  • Why has my connection AirPort Extreme recently stopped with my Tablet Android and Windows 7 laptop, but connects very well with all Apple devices?

    Why has my connection AirPort Extreme recently stopped with my Tablet Android and Windows 7 laptop, but connects very well with all Apple devices?

    What exact model of AirPort Extreme do you have? Either have your tablet or laptop Win7 been updated recently? They were both able to connect before and not now OR they were never able to connect? Can the laptop Win7 access Internet when connected by Ethernet? One of these devices have problems connecting to other networks Wi - Fi?

  • After the update to OS 9.2.1 connection of my mini iPad with a VGA projector no longer works... Any clue?

    After the update to OS 9.2.1 connection of my mini iPad with a VGA projector no longer works... Any clue? Thank you

    Try resetting your device. This will not erase your data stored on that device.

    • Press and hold the sleep/wake button
    • Press and hold the Home button
    • Press and hold both buttons until the display turns off and on again with the Apple logo on the subject.

    Alternatively, you can go to settings - general - reset - Reset all settings

    If that doesn't work, restore your device to factory settings. Please note that this will delete the data on your device.

    Take a look this Apple Support article: use iTunes to restore the iPhone, iPad or iPod to factory settings - Apple Support.

Maybe you are looking for

  • Set up alerts for different e-mail accounts

    I am using the default mail app and I have several inside accounts (GMail / iCloud / job Exchange account). Is it possible to change the way each account warns me? For example, sometimes I do want my GMail account to play a sound when new messages. F

  • Analysis & postprocessor

    Dear all, I would like to know the use of an equation in "Add the phrase" any analysis and "Post processor"? What will be the difference that can be viewed in the Grapher view? » Thanks in advance, Samir.

  • How to determine the E4200 V1 or V2?

    Pages support and registration for the E4200 wireless router ask if I have a router V1 or V2. There is no place on the real router which identify it as V1 or V2, and Cisco Connect app does not display this information. What I know is the following: M

  • Vista and Windows 7

    I have an old beta software on my computer that has worked with Vista.  Now that I have windows 7, it does not open.  It is E-Cookbook v1.0.0 b - a simple database program. I lose recipes that I've already put in. I can do something special to do ope

  • BlackBerry Smartphones Outlook message conversion first read on Blackberry in plain text in Outlook

    Y at - it a fix for this problem? If I read my messages first on my Blackberry and then then open Outlook - the message is converted to plain text in Outlook... It's annoying when I usually respond to messages in Outlook and want them to be in HTML f