Signals and Slots

Try to test something after that someone wanted to help with the signals and Slots sorta. I know there is an alternative to this, but I'm trying to understand why this does not work when doing it this way.  It relies, it works but it does not fly... I mean this isn't the trigger of the SLOT feature... Not even sure if she sends a SIGNAL...

Thanks in advance.

file:

// Default empty project template
#ifndef Testme_HPP_
#define Testme_HPP_

#include 

namespace bb { namespace cascades { class Application; }}
namespace bb { namespace cascades { class TouchEvent; }}
namespace bb { namespace cascades { class Container; }}
namespace bb { namespace cascades { class ImageView; }}

/*!
 * @brief Application pane object
 *
 *Use this object to create and init app UI, to create context objects, to register the new meta types etc.
 */
class Testme : public QObject
{
    Q_OBJECT
public:
    Testme(bb::cascades::Application *app);
    virtual ~Testme() {}
public slots:
    void handleTouch(bb::cascades::TouchEvent* tEvent);
private:
    bb::cascades::Container* rootContainer;
    bb::cascades::ImageView* imgView;
};

#endif /* Testme_HPP_ */

.cpp file:

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

#include 
#include 
#include 
#include 
#include 
#include 

using namespace bb::cascades;

Testme::Testme(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);
    QmlDocument *qml2 = QmlDocument::create("asset:///Testingme.qml").parent(this);

    // create root object for the UI
    AbstractPane *root = qml->createRootObject();
    // set created root object as a scene
    app->setScene(root);

    if (!qml2->hasErrors()) {
        rootContainer = qml2->createRootObject();

        if (rootContainer) {
            imgView = rootContainer->findChild("imgView");

            if (imgView) {
                bool res = QObject::connect(imgView,                                        SIGNAL(touch(bb::cascades::TouchEvent*)),
                        this, SLOT(handleTouch(bb::cascades::TouchEvent*)));
                Q_ASSERT(res);
                Q_UNUSED(res);
                fprintf(stderr, "Height: %f and width: %f\n",
                        imgView->preferredHeight(),                                        imgView->preferredWidth());
            } else {
                fprintf(stderr, "No ImageView\n");
            }
        } else {
            fprintf(stderr, "No root container\n");
        }
    } else {
        fprintf(stderr, "QML2 has errors\n");
    }
}

void Testme::handleTouch(TouchEvent *tEvent)
{
    fprintf(stderr, "Touch Touch Touch\n");
}

hand file. QML:

// Default empty project template
import bb.cascades 1.0

// creates one page with a label
Page {
    Container {
        layout: StackLayout {}
        Label {
            text: qsTr("Hello World")
        }

        Testingme {
            id: testingMe
        }
    }
}

File Testingme.QML:

import bb.cascades 1.0

Container {
    objectName: "rootContainer"
    horizontalAlignment: HorizontalAlignment.Center
    verticalAlignment: VerticalAlignment.Center
    background: Color.create ("#262626")

    ImageView {
        objectName: "imgView"
        imageSource: "asset:///belligerent.png"
        preferredHeight: 200
        preferredWidth: 200
    }
}

The main file is the one you get when you create a new project of Cascades Standard default. So, what's wrong with this picture? Or of images, other than the fact that I use the png of bellicose blocks file...

-Edit (this and some formatting).

I'm using the Simulator, so don't know if it would make a difference. BTW, I even tried to use a checkbox, and which does not trigger anything.

Well, it works eventually got. I'm still not sure where to check signals during debugging, however.

Although there are two files QML, the first main QML object is one that should be used. I used the 2nd QML file object that was wrong, even if the image is in the 2nd...

Tags: BlackBerry Developers

Similar Questions

  • Problem, the signals and Slots

    Hi, as I posted in one of my other posts I have following problem with signals and messages and would be nice if someone could clarify anything that I don't seem to be able to find what the problem of the outputs.

    I have the code:

    void MYNetworkClass::requestFinished(QNetworkReply* reply)
    {
    
          // Check the network reply for errors
          if (reply->error() == QNetworkReply::NoError)
          {
             // read response
             const QByteArray response(reply->readAll());
             qDebug() <<"Response: "<< response;
    
             JsonDataAccess jda;
             QVariantMap results = jda.loadFromBuffer(response).toMap();
    
             QVariantMap data = results.value("SomeData").toMap();
    
             emit signalSuccess(data); // I reach here .... 
    
    // however actually when I click "Step Over" in debug mode, and try to exit the function// afterwards I get such "error" saying: No source available for "QMetaObject::activate() at  0xb9668da7" - highlighted in red.
    
         }
         else
         {
             qDebug() << "\n Problem with the network";
             qDebug() << "\n" << reply->errorString();
         }
    

    In MyNetwork class I also added the definition of signal in the header file:

    signals:
    
        void signalSuccess(QVariantMap result);
    

    Now also when someone calls an object MyNetworkClass method which calls requestFinished,.

    I want to catch the signal which is emitted by the requestFinished - as shown above.

         MyNetworkClass *network = new MyNetworkClass();
    
        QMap params;
        params.insert("username", userEmail);
    
        bool res = QObject::connect(network, SIGNAL(signalSuccess(QVariantMap)), this, SLOT(SomeSlotForSignal(QVariantMap)));
    
            Q_ASSERT(res);
        Q_UNUSED(res);
            network->makePostRequest("Login");
    

    My problem is that the SomeSlotForSignal slot never is called... (even if the signal is issued constitute requestFinished method and as I stated SomeSlotForSignal as a crack in the header file...) What can be problem? Any help? Thank you.

    I guess I solved the problem.

    The code I presented previously registered function

    F of a class B:

     void B::f()
    {
    MyNetworkClass *network = new MyNetworkClass();
    
        QMap params;
        params.insert("username", userEmail);
    
        bool res = QObject::connect(network, SIGNAL(signalSuccess(QVariantMap)), this, SLOT(SomeSlotForSignal(QVariantMap)));
    
            Q_ASSERT(res);
        Q_UNUSED(res);
    
    network->makePostRequest("Login");
    }
    

    Then the function f is called to:

        B object;
        object.f();
    
    The problem was I think that when the server responded "object" was destroyed from the stack. When I replaced the above code, with 
    
         B* object = new B();
        object->f();
    
    I think it works now......
    
  • Unable connect 2 classes of signals and Slots

    I am transferring from one category to the other channels.

    Their memories are:

    .hpp files------------
    class A::public QObject{
    Q_OBJECT
    
    signals:
    void emitMsg(QString* msg);
    }
    
    class B::public QObject{
    signals:
    void emitA(QString* msgA);
    public slots:
    void logMsg(QString* msg);
    }
    
    ---------.cpp files
    
    classB::classB(){
    bool temp= connect(objB,SIGNAL(emitA(QString*)),this,SLOT(logMsg(QString*)));
    
    qDebug()<<"value="<
    

    But even running in the device debug mode Dev Alpha, the application displays a value in the log messages, or moves out of the screen dark splash.

    Please adivse, what is missing from the other code?

    Is there a way by which the slots and signals of different classes could be connected to data transfer?

    Create a Downloader object?

    (BTW, I always initialize pointers to 0 in the initializer list.)  Who does this kind of obvious thing, and it has the same thing for debug and release)

    Stuart

  • Why connecttng signals and slots of an element of action gets segfault

    I add an action item to a page. For some reasong I had to disconnect the item, delete and re-create, and then reconnect it. But I am getting exception when I try to pull the plug. If I omit the disconnection then I get exception when connecting. My code is below

      if(addAllRules)
        {
            disconnect(addAllRules,SIGNAL(triggered()),this,SLOT(onTriggeredAddRuleActionAllRules()));
            delete(addAllRules);
        }
        addAllRules =  ActionItem::create().title("Add Rule").enabled(true);
        allRulesPage->addAction(addAllRules, ActionBarPlacement::OnBar);
        connect(addAllRules,SIGNAL(triggered()),this,SLOT(onTriggeredAddRuleActionAllRules()));
    

    Have you tried cleaning and reconstruction project?

    You will need to find the exact location of the crash using a debugger or newspapers, or analyze a dump core after accident.

    This can also occur due to memory corruption. If the memory is damaged from somewhere, the accident can happen in completely independent place. In this case, try commenting on most of the features of the application until the QTimer started working restaurant then step by step.

  • How to get the callUpdated signal and respond to the function of oncallUpdated slot?

    Hello world:

    I want to get the 'phone. callUpdated (const bb::system:: call & appeal) "signal and do something in the slot to onCallUpdated function, but the problem is crack onCallUpdated() function does NOT respond!

    Here is my code:

    . CPP

    #include 
    

    MyApp (bb::cascades:Application * app) in myApp.cpp

        bb::system::phone::Phone phone;
    
        bool success = QObject::connect(&phone,SIGNAL(callUpdated(const bb::system::phone::Call&)),this,SLOT(onCallUpdated(const bb::system::phone::Call&)));
    
        qDebug()<<"bb::system::phone::Phone phone:  "<
    

    When the application runs, the success of back connect is true!

    void Quicker::onCallUpdated(const bb::system::phone::Call &call)
    {
    
        //CallState::Type state = call.callState();
    
        qDebug()<<"onCallUpdated is called";
    }
    

    In myApp.hpp

    #include 
    
         void onCallUpdated(const bb::system::phone::Call &call);
    

    In the bar - descriptor.xml

        run_when_backgrounded
        access_phone
    

    I found the problem:

    bb::system::phone::Phone phone;
    

    the code must be in the *.hpp.

    Thank you all.

  • IPhone 5 s losing signal and MIC is muffled

    Hello guys,.

    My Rich Dad a 5s iPhone and it loses signal and muffled the sound when he talks about phone! Any solution before going to the apple service?

    Hello

    Try following the steps here in terms of sound not clear:

    Get help with microphones on your iPhone, iPad and iPod touch - Apple Support

    Follow the instructions in respect of the loss of cellular signal:

    If you cannot connect to a cellular network or cellular data - Apple Support

  • I am facing a problem with the beep.vi. I have a DAQ program, which acquired the signal and compare it to a threshold value. When a signal is out of range, a Visual and sound alarm has occurred. I use the VI beep.vi to generate the sound.

    I am facing a problem with the beep.vi.  I have a DAQ program, which acquired the signal and compare it to a threshold value. When a signal is out of range, a Visual and sound alarm has occurred. I use the VI beep.vi to generate the sound. Everything works fine except the sound alarm. It gives the table 1 d of type mismatch. I tried to fix this by placing it in a box structure. But it still does not work. If someone could help? Please find attached my VI. Best wishes to all visitors to the Forums of Discussion OR.

    Ihab El-Sayed

    published here: http://forums.ni.com/t5/LabVIEW/Playing-sound-based-on-exceeding-a-threshold-value-1D-array-data/m-p...

  • Align the two signals and measure the Phase Shift

    Hello

    I do an experiment in which I use the NI USB-6221 DAQ card. The jury is able to make 250 k samples/second. I want to measure two voltages in a circuit and find the phase shift between them at frequencies between 1 and 10000. First I ouputted a wave sinusoidal frequency variable through the Commission and applied to a test circuit. Then I used the Board to measure the two tensions consecutively (thus reducing the maximum sampling frequency at 125 k). I used the signals align VI and measured the two phases and then calculates the phase shift (VI attached in Phase 1). It worked well for the test circuit I built in which the phase shift went way logarithmique.20 degrees ~84.5 degrees and then stabilized. At frequencies above 5 000 Hz phase shift must have remained constant, but it varies more or less 1 degree. When the phase shift is 84.5 degrees, present a degree of variability is not particularly explicit. When I asked my program on the circuit that I really wanted to measure, the phase shift went from-. 5 degrees up to about 1.2 degrees. The change in the values of phase shift at high frequencies (> 3000) was environ.2 degrees. Given the small phase shift, this variation is unacceptable. Now I tried to use a sequence to each blood individually (increase the maximum sampling frequency to 250 k) and then align the two signals and measure the phase of each shift. When I use align it and re - sample Express VI to realign the two signals, I get the message "error 20333 analysis: cannot align two waveforms with dt even if their samples are not clocked in phase." Is it possible to align two signals I describe here? I enclose the new VI as Phase 2

    Matthew,

    I think I have an idea for at least part of the problem.

    I took your program data and deleted stuff DAQ.  I have converted the Signal on the chart control and looked then what was going on with the signal analysis.

    The output of the Waveforms.vi line has two waveforms, like the entry.  However, arrays of Y in the two waveforms are empty!  It does not generate an error. After some head scratching, reading the help files and try things out, that's what I think is happening: the time t0 two input signals are 1,031 seconds apart. Since the wavefoms contains 1,000 seconds of data, there is no overlap and may not align them.

    I changed the t0 on two waveforms are the same, and it lines up.  The number of items in the tables is reduced by one. Then I increased the t0 of 0.1 seconds on the first element. The output had both greater than the entry by dt t0 t0 and the size of the arrays was 224998.  Reversing the t0 two elements shifts the phase in the opposite direction.

    What that tells me, is that you can not reliably align two waveforms which do not overlap.

    I suggest that you go to 2-channel data acquisition and that it accept the reduced sample rate.  You won't get the resolution you want, but you should be able to tell if something important happens.

    You may be able to improve the equivalent resolution by taking multiple steps with a slight phase shift. This is similar to the way that old oscilloscopes of sampling (analog) worked. Take a series of measures with the signal you are currently using.  The make enough average to minimize changes due to noise. Then pass the phase of the signal of excitement to an amount that is smaller than the resolution of phase of sampling rate and repeat the measurements.  Recall that I calculated that for a 5 kHz signal sampled at 125kHz, you get a sample every 14.4 degrees. If shift you the phase of 1 degree (to the point/mathematical simulation), you get a different set of samples for excitement.  They are always separated by 14.4 degrees.  Take another series of measures. Transfer phase another degree and repeat.  As long as your sampling clocks are stable enough so that frequency does not drift significantly (and it shouldn't with your equipment), you should be able to get near resolution of what you need.  The trade-off is that you need to perform more measurements and may need to keep track of the phase shifts between the various measures.

    Lynn

  • How do I get the analog input signal and send it to output analog (real time)

    Hello world

    I do a simple task in Visual C++ and I use PCI-6221(37 pin).

    Basically, I want to send the same signal of "analog input" to the "analog output".

    at the same time (or almost), to make real-time application.

    Can someone provide me with sample program please.

    I would be grateful if you could provide me with the great tutorial that explains

    step by step everything about NOR-DAQmx for C/C++ programming.

    Best regards

    Khassan

    This is my code in C++, you can optimize it if that seems too messy. This code reads the analog input signals and exports it through the analog outputs.

    To make this code additional work of the directories include and library directories must be added to OR.

    I hope it helps someone.

    #include
    #include
    #include "NIDAQmx.h".
    #include

    #define DAQmxErrChk (functionCall) {if (DAQmxFailed (error = (functionCall))) {goto error ;}}

    int main (int argc, char * argv [])
    {
    Int32 error = 0;
    TaskHandle taskHandleRead = 0, taskHandleWrite = 0;
    Read Int32 = 0;
    float64 context [1000];
    char errBuffRead [2048] = {'\0'};
    char errBuffWrite [2048] = {'\0'};
    bool32 done = 0;
    Int32 wrote;

    DAQmxErrChk (DAQmxCreateTask("",&taskHandleRead));
    DAQmxErrChk (DAQmxCreateAIVoltageChan(taskHandleRead,"Dev1/ai0","",DAQmx_Val_Cfg_Default,-10.0,10.0,DAQmx_Val_Volts,NULL));
    DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandleRead,"",100.0,DAQmx_Val_Rising,DAQmx_Val_ContSamps,0));
    DAQmxErrChk (DAQmxCreateTask("",&taskHandleWrite));
    DAQmxErrChk (DAQmxCreateAOVoltageChan(taskHandleWrite,"Dev1/ao0","",-10.0,10.0,DAQmx_Val_Volts,NULL));
    DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandleWrite,"ai/SampleClock",100.0,DAQmx_Val_Rising,DAQmx_Val_ContSamps,1000));

    DAQmxErrChk (DAQmxStartTask (taskHandleRead));
    DAQmxErrChk (DAQmxStartTask (taskHandleWrite));

    While (! fact &! _kbhit())

    {

    DAQmxErrChk (DAQmxReadAnalogF64(taskHandleRead,1,10,DAQmx_Val_GroupByScanNumber,dataRead,1000,&read,));

    DAQmxErrChk (DAQmxWriteAnalogF64(taskHandleWrite,read,0,10.0,DAQmx_Val_GroupByChannel,dataRead,&written,));

    }
    _getch();

    Error:
    If (DAQmxFailed (error))

    {
    DAQmxGetExtendedErrorInfo (errBuffRead, 2048);
    DAQmxGetExtendedErrorInfo (errBuffWrite, 2048);
    }
    If (taskHandleRead! = 0)

    {

    DAQmxStopTask (taskHandleRead);
    DAQmxClearTask (taskHandleRead);
    }
    If (taskHandleWrite! = 0)

    {

    DAQmxStopTask (taskHandleWrite);
    DAQmxClearTask (taskHandleWrite);
    }
    If {(DAQmxFailed (error))
    printf ("error DAQmx: %s\n",errBuffRead); ")
    printf ("error DAQmx: %s\n",errBuffWrite); ")
    }
    printf ("end of the program, press the Enter key to quit\n");
    GetChar ();
    return 0;
    }

  • acquisition of wireless signals and record the signal as text at the same time for 5 minutes

    Hello

    I'm wireless ECG signal and the display in waveform graph. And at the same time, I need to save it as text for 5 minutes. The problem I faced is for record of the signal, I use scripture to the extent file that saves the file as text... but everything by saving the trace speed decreases.

    I'm very new to labview so please can someone me if Miss me something in it... Please help...

    Why people always post photos of their screws rather than the screws themselves or at least excerpts?  We can't tell from the picture what Version of LabVIEW, you use (so if we post code, you will not be able to open it), and we can not 'play' with your code and try without, ourselves, by hand, trying to recreate your diagram (sometimes very small).  Please, help us help you!

    This is in any case helps to familiarize yourself with the design of producer/consumer model.

    1. Open LabVIEW.
    2. Click on 'File', choose 'new '.... "(no new VI), then (in models) producer/consumer Design Pattern (data).
    3. Study the model and adapt it to your problem.

    The producer would be anything that generates data.  Once you have the data, you put on the queue and send to the consumer for the entire treatment.  The idea is that the producer has an inherent calendar that he must answer, otherwise you lose data points.  The consumer, on the other hand, just need to follow 'more or less' (in fact, the queue may / will develop, if the amount of data is not megabytes, so the consumer can really be quite slow, if you usually want to consumers, on average, to be at least as fast as the producer).

    Bob Schor

  • How to enter a wireless signal and convert Ethernet cable?

    I'm totally bafled by the nomenclature of wireless gadgets and would appreciate help. I already have a wireless router that allows my laptop work anywhere in my house. My need is to recover the wireless signal and somehow get this signal into an Ethernet cable.

    The reason is that my DVR (Replay TV) connects to Internet via Ethernet (not USB) cable and I want to move to a place where it would be impractical to try the new wiring through the walls.

    Thank you!

    You need a "wireless ethernet bridge", like the WET54G, WET200 or WET610N.  Once you set up the device, just wire your DVR to it.

  • Im having truoble internet connection, even if I have a signal and everything is connected

    Im having truoble internet connection, even if I have a signal and everything is connected.  I ran the repairs and doing what he had asked, however I am still unable to connect to the internet?

    I have a WiFi router, and even if my desktop pc lacks a coneection wirless, I bought a wireless adapter for it, so I can connect to the internet, but there is a problem with the connection.  everything worked fine and then it just stopped and refuses to connect. I run the diagnostic report and followed the instructions but it does not connect truncated.  What can I gdo now?

    Hello

    1. you get any error message?

    2. don't you make changes to the computer before the show?

    Please follow the steps below.

    Method 1:

    Follow the steps mentioned in the links below

    Windows wireless and wired network connection problems

    http://Windows.Microsoft.com/en-us/Windows/help/wired-and-wireless-network-connection-problems-in-Windows

    Solve problems, find wireless networks

    http://Windows.Microsoft.com/en-us/Windows-Vista/troubleshoot-problems-finding-wireless-networks (Also applies to Windows 7)

    Method 2:

    Follow the steps mentioned in the link below.

    http://Windows.Microsoft.com/en-us/Windows7/how-do-I-fix-network-adapter-problems

  • The difference between the strength of the signal and quality?

    Hi all

    According to the Cisco documentation

    Low RF signal strength does not mean the lack of communication.

    The quality of the signal is low means poor communications.

    If someone can explain to me the difference between the power of the signal and the quality of the signal?

    In accordance with my AP home I see that this signal strength is measured in numbers like 50% or 100%.

    But what is the quality of the signal and how to measure me?

    Thank you

    Mahesh

    Big question...

    First, let's look at the notion of signal quality and strength... Suppose for a minute you're front row at a rock concert right next to the speakers. Sound is loud, you can't hear anything else that scream. It is an example of a strong signal but poor quality.

    As for the signal and the noise of measurement or should we say quality of signal. Providers sometimes give you a % or dB scale when ranking signal. You can't really do headers or tails of the % scale because each vendor has % different measures. But check your access point, because you will be able to change in dB.

    Look at dBm. At the moment my client shows:

    Signal - 59 dBm

    Noise - 98 dBm

    The dB scale is simple. More PB the STRONGEST signal. You'll see - 59 of the signal is good, in fact, I'm about 50 feet from the AP. If you are under the ap you will get as a - 30ish. Noise, we do not want to be noisy, if we want to see the noise to-100. More low is the dB of noise as loud noise.

    So we're back out the example above. Next to the speaker, you're showing tell - 30dBm, but your noise can be as - 70dBm...

    Does make sense?

    Normally, you want to see your signal not exceeding 67 - not for voice or - 76 for the data. And your noise should be greater than-90.

  • Can I connect wireless and wired to the Airport Extreme even? My House has plaster walls that inhibit the signal and I move to my office.

    I have a good Wi - fi network at home using an Airport Extreme and Airport Express, but am moving my office on the other side of the House. The walls are plaster that inhibit the signal. Can I connect another Express to my extreme via an Ethernet cable for the office. I still maintain the wireless network. Thanks for your help.

    Yes, it's the right way to do things.

    Only the express will not extend the wireless... you create a wireless network of the same name and security settings... This is called roaming network.

  • How analog out simultaneously a signal and its negation?

    Hello

    I use the 6024E and trying to send a signal with an analog output.

    However, at the same time, I would like to send a negation of this the other analog output signal.

    It seemed simple until I realized that this timed task alone is supported at a time.

    Any suggestions would be most appreciated... I have attached the vi I thought that (but now realize will never) work.

    Thank you!

    You should be able to put the two channels in the same spot.  Not had time to test this, but it should work.

Maybe you are looking for