Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

New Contributor
Posts: 2
Registered: ‎10-18-2012
My Device: BlackBerry10Simulator-BB10_0_09-386
My Carrier: SiBlackBerry10Simulator-BB10_0_09-386

QT QNetworkAccessManager and Signals

I have a class (RequestHandler) that I call from my main Application class to call various web services. Once a service has completed the class sends a Signal back to the calling class to say that it has finished(possibly with QString message). I have the Signal working in a test method but the QNetworkAccessManager is not working at all. I am quite new to QT and C++. Thanks for your help.


// RequestHandler.h

    #include <QNetworkAccessManager>
    #include <QUrl>
    #include <QNetworkRequest>
    #include <QNetworkReply>
    #include <QOBJECT>
    #include "MainAppClass.hpp"

    class RequestHandler : public QObject

        explicit RequestHandler(QObject *parent = 0);
        void validateRegistration(QString reg);
        void onStatusUpdateCompleted();
        void sayHi();

        void sendSignal(QString txt);
        QNetworkAccessManager* manager;
        QObject* thisObj;

    public slots:
        void onRequestCompleted();

    #endif /* REQUESTHANDLER_H_ */

// RequestHandler.cpp
    #include "RequestHandler.h"

    RequestHandler::RequestHandler(QObject *parent) : QObject(parent)
        thisObj= parent;
    void RequestHandler::validateRegistration(QString reg) {
        QNetworkRequest request;
        manager = new QNetworkAccessManager();
        QNetworkReply *reply = manager->get(request);
        connect(reply, SIGNAL(finished()), this, SLOT(onRequestCompleted()));
    void RequestHandler:Smiley SurprisednRequestCompleted() {
        // not getting here at all
    void RequestHandler::sayHi()
        // this is working
        QObject::connect(this, SIGNAL(sendSignal(QString)), thisCellCast,   SLOT(recieveValue(QString)));
        emit sendSignal("HERES THE SIGNAL");

I am calling this class like this:


// test slots and reg
    RequestHandler rh(this);
// not working

Thanks for your help.

Posts: 526
Registered: ‎05-17-2009
My Device: 9900
My Carrier: ATT

Re: QT QNetworkAccessManager and Signals

The method signature for the finished signal has arguments, your signals and slots need to match up exactly with what is defined for the class.

Also try connecting to the finished(QNetworkReply*) signal from the manager instead of finished from the reply.

Theres tons of things that could be going wrong here, hook up to the error signals too.
Like all of my posts