title: QT C++ - Signals and Slots: "No such slot QLabel..." even the SLOT function is existing in my class
body: <p>So I am trying to learn Qt Framework with C++. I am in the middle of understanding signals and slots but I am having a hard time creating a customized slot. So as I follow some tutorials, my program ended up with the following error:</p>
  
  <blockquote>
    <p>QObject::connect: No such slot QLabel::updateMessage() in main.cpp:28</p>
  </blockquote>
  
  <p>Where <strong>updateMessage()</strong> is declared as a <strong>public slot</strong> inside my <strong>Test</strong> class</p>
  
  <p>The following are some snippets from my code:</p>
  
  <p><strong>Test.h</strong></p>
  
  <pre><code>class Test : public QObject
  {
      Q_OBJECT
  public:
      Test(void);
      ~Test(void);
      void setMessage(char *tMsg);
      char* getMessage();
  
      QWidget *window;
      QGridLayout *layout;
      QLabel *lblMsg;
      QPushButton *btnShow;
  
  
  public slots:
      void updateMessage();
  
  private:
      char msg[80];
      QString str;
  
  };
  </code></pre>
  
  <p><strong>main.cpp</strong></p>
  
  <pre><code>int main(int argc, char *argv[])
  {
      QApplication app(argc, argv);
      Test t;
      t.window-&gt;setWindowTitle("Testing Qt");
      t.window-&gt;setLayout(t.layout);
      t.window-&gt;show();
      return app.exec();
  }
  
  Test::Test(void)
  {
      window = new QWidget;
      lblMsg = new QLabel;
      btnShow = new QPushButton("Show message");
  
      connect(btnShow,SIGNAL(clicked()),lblMsg,SLOT(updateMessage()));
      layout = new QGridLayout;
      layout-&gt;addWidget(lblMsg);
      layout-&gt;addWidget(btnShow);
  
      char str1[] = "Hello, Qt World!";
      setMessage(str1);
  }
  
  
  Test::~Test(void)
  {
  
  }
  
  void Test::setMessage(char *tMsg)
  {
      memcpy(msg, tMsg, sizeof(msg));
  }
  
  char* Test::getMessage()
  {
      return msg;
  }
  
  void Test::updateMessage()
  {
      string strMsg(getMessage());
      QString qstr = QString::fromStdString(strMsg);
      lblMsg-&gt;setText(qstr);
      delete msg;
  }
  </code></pre>
  
  <p><strong>HelloQtWorld.pro</strong></p>
  
  <pre><code>######################################################################
  # Automatically generated by qmake (3.0) Tue Nov 15 00:30:22 2016
  ######################################################################
  
  TEMPLATE = app
  TARGET = HelloQtWorld
  INCLUDEPATH += .
  
  # Input
  HEADERS += stdafx.h Test.h
  SOURCES += anotherClass.cpp \
             main.cpp \
             stdafx.cpp \
             GeneratedFiles/qrc_helloqtworld.cpp
  RESOURCES += helloqtworld.qrc
  </code></pre>
  
  <p>Can also someone try to explain for me how Signals and Slots work? Thank you in advance. :)</p>