Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Signal/Slot connection problem [signal from one class to other class]
Forum Updated to NodeBB v4.3 + New Features

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

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 636 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tesmai4
    wrote on last edited by
    #1

    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?

    1 Reply Last reply
    0
    • Chris KawaC Offline
      Chris KawaC Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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?

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved