Signal/Slot connection problem [signal from one class to other class]



  • I am having problem in executing my signal/slot connection for the following scenario:

    @
    class NetworkClient : public QObject
    {
    Q_OBJECT

    public:
    int forwardResponse();

    signals:
    void sigClientResponse();
    }@

    @
    NetworkClient::NetworkClient()
    {
    }

    int NetworkClient::forwardNetworkResponse()
    {
    ...
    ...
    ...
    emit sigClientResponse();
    }@

    @
    class MyGUI : public QMainWindow
    {
    Q_OBJECT
    NetworkClient* myClient;

    private slots:
    void slotClientResponse();
    }@

    @
    MyGUI::MyGUI(QWidget *parent) : QMainWindow(parent), ui(new Ui::MyGUI)
    {
    ui->setupUi(this);

    connect(myClient,SIGNAL(sigClientResponse()), this, SLOT(slotClientResponse()));
    }@

    My signal is emitted, however the slot is not executed. Can anybody help in identifying the problem?


  • Moderators

    You connect the signal in MyGUI constructor.
    Is myClient variable initialized at this point?
    Does MyGUI instance exist at the time the signal is emitted?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.