Qt Connect Signals to Slots
<p>I am trying to connect a signal. But I keep on encountering this. I am sure that I have linked up the *.h file which contains QAction *actionCameraSetup. Am I missing anything out?</p>

<p>Please help.
Thanks.</p>

<p>Error:</p>

<blockquote>
  <p>1>camera.cpp 1>.\camera.cpp(10) : error C2065: 'actionCamera_Setup' :
  undeclared identifier</p>
</blockquote>

<p><strong>camera.cpp</strong></p>

<pre><code>#include "camera.h"
#include "camera_setup.h"
#include "ui_camera.h"

Camera::Camera(QWidget *parent, Qt::WFlags flags)
    : QMainWindow(parent, flags)
{
    ui.setupUi(this);

    connect(actionCamera_Setup, SIGNAL(activated()), this, SLOT(openCameraSetup()));
}

Camera::~Camera()
{

}

void Camera::openCameraSetup()
{
    newCameraSetup = new camera_setup();
    newCameraSetup-&gt;show();
}
</code></pre>

<p><strong>camera.h</strong></p>

<pre><code>#ifndef CAMERA_H
#define CAMERA_H

#include &lt;QtGui/QMainWindow&gt;
#include "ui_camera.h"
#include "ui_camera_setup.h"

class camera_setup;

class Camera : public QMainWindow
{
    Q_OBJECT

public:
    Camera(QWidget *parent = 0, Qt::WFlags flags = 0);
    ~Camera();

public slots:
    void openCameraSetup();

private:
    Ui::CameraClass ui;
    camera_setup *newCameraSetup;
};

#endif // CAMERA_H
</code></pre>

<p><strong>ui_camera.h</strong></p>

<pre><code>#ifndef UI_CAMERA_H
#define UI_CAMERA_H

#include &lt;QtCore/QVariant&gt;
#include &lt;QtGui/QAction&gt;
#include &lt;QtGui/QApplication&gt;
#include &lt;QtGui/QButtonGroup&gt;
#include &lt;QtGui/QGridLayout&gt;
#include &lt;QtGui/QHeaderView&gt;
#include &lt;QtGui/QLabel&gt;
#include &lt;QtGui/QMainWindow&gt;
#include &lt;QtGui/QMenu&gt;
#include &lt;QtGui/QMenuBar&gt;
#include &lt;QtGui/QWidget&gt;

class QAction;

QT_BEGIN_NAMESPACE

class Ui_CameraClass
{
public:
    QAction *actionExit;
    QAction *actionCamera_Setup;
    QAction *actionFull_Screen;
    QAction *action1_Camera_1;
    QAction *action1_Camera_2;
    QAction *action1_Camera_3;
    QAction *action1_Camera_4;
    QAction *action1_Camera_5;
    QAction *action1_Camera_6;
    QAction *action2_Camera_1;
    QAction *action2_Camera_2;
    QAction *action2_Camera_3;
    QAction *action2_Camera_4;
    QAction *action2_Camera_5;
    QAction *action2_Camera_6;
    QWidget *centralWidget;
    QGridLayout *gridLayout;
    QLabel *label_CCV;
    QMenuBar *menuBar;
    QMenu *menuFile;
    QMenu *menuView;
    QMenu *menuCameras;

    void setupUi(QMainWindow *CameraClass)
    {
        if (CameraClass-&gt;objectName().isEmpty())
            CameraClass-&gt;setObjectName(QString::fromUtf8("CameraClass"));
        CameraClass-&gt;resize(600, 367);
        actionExit = new QAction(CameraClass);
        actionExit-&gt;setObjectName(QString::fromUtf8("actionExit"));
        actionCamera_Setup = new QAction(CameraClass);
        actionCamera_Setup-&gt;setObjectName(QString::fromUtf8("actionCamera_Setup"));
        actionFull_Screen = new QAction(CameraClass);
        actionFull_Screen-&gt;setObjectName(QString::fromUtf8("actionFull_Screen"));
        action1_Camera_1 = new QAction(CameraClass);
        action1_Camera_1-&gt;setObjectName(QString::fromUtf8("action1_Camera_1"));
        action1_Camera_2 = new QAction(CameraClass);
        action1_Camera_2-&gt;setObjectName(QString::fromUtf8("action1_Camera_2"));
        action1_Camera_3 = new QAction(CameraClass);
        action1_Camera_3-&gt;setObjectName(QString::fromUtf8("action1_Camera_3"));
        action1_Camera_4 = new QAction(CameraClass);
        action1_Camera_4-&gt;setObjectName(QString::fromUtf8("action1_Camera_4"));
        action1_Camera_5 = new QAction(CameraClass);
        action1_Camera_5-&gt;setObjectName(QString::fromUtf8("action1_Camera_5"));
        action1_Camera_6 = new QAction(CameraClass);
        action1_Camera_6-&gt;setObjectName(QString::fromUtf8("action1_Camera_6"));
        action2_Camera_1 = new QAction(CameraClass);
        action2_Camera_1-&gt;setObjectName(QString::fromUtf8("action2_Camera_1"));
        action2_Camera_2 = new QAction(CameraClass);
        action2_Camera_2-&gt;setObjectName(QString::fromUtf8("action2_Camera_2"));
        action2_Camera_3 = new QAction(CameraClass);
        action2_Camera_3-&gt;setObjectName(QString::fromUtf8("action2_Camera_3"));
        action2_Camera_4 = new QAction(CameraClass);
        action2_Camera_4-&gt;setObjectName(QString::fromUtf8("action2_Camera_4"));
        action2_Camera_5 = new QAction(CameraClass);
        action2_Camera_5-&gt;setObjectName(QString::fromUtf8("action2_Camera_5"));
        action2_Camera_6 = new QAction(CameraClass);
        action2_Camera_6-&gt;setObjectName(QString::fromUtf8("action2_Camera_6"));
        centralWidget = new QWidget(CameraClass);
        centralWidget-&gt;setObjectName(QString::fromUtf8("centralWidget"));
        gridLayout = new QGridLayout(centralWidget);
        gridLayout-&gt;setSpacing(0);
        gridLayout-&gt;setContentsMargins(0, 0, 0, 0);
        gridLayout-&gt;setObjectName(QString::fromUtf8("gridLayout"));
        label_CCV = new QLabel(centralWidget);
        label_CCV-&gt;setObjectName(QString::fromUtf8("label_CCV"));

        gridLayout-&gt;addWidget(label_CCV, 0, 0, 1, 1);

        CameraClass-&gt;setCentralWidget(centralWidget);
        menuBar = new QMenuBar(CameraClass);
        menuBar-&gt;setObjectName(QString::fromUtf8("menuBar"));
        menuBar-&gt;setGeometry(QRect(0, 0, 600, 21));
        menuFile = new QMenu(menuBar);
        menuFile-&gt;setObjectName(QString::fromUtf8("menuFile"));
        menuView = new QMenu(menuBar);
        menuView-&gt;setObjectName(QString::fromUtf8("menuView"));
        menuCameras = new QMenu(menuView);
        menuCameras-&gt;setObjectName(QString::fromUtf8("menuCameras"));
        CameraClass-&gt;setMenuBar(menuBar);

        menuBar-&gt;addAction(menuFile-&gt;menuAction());
        menuBar-&gt;addAction(menuView-&gt;menuAction());
        menuFile-&gt;addAction(actionExit);
        menuView-&gt;addAction(menuCameras-&gt;menuAction());
        menuView-&gt;addAction(actionCamera_Setup);
        menuView-&gt;addSeparator();
        menuView-&gt;addAction(actionFull_Screen);
        menuCameras-&gt;addAction(action1_Camera_1);
        menuCameras-&gt;addAction(action1_Camera_2);
        menuCameras-&gt;addAction(action1_Camera_3);
        menuCameras-&gt;addAction(action1_Camera_4);
        menuCameras-&gt;addAction(action1_Camera_5);
        menuCameras-&gt;addAction(action1_Camera_6);
        menuCameras-&gt;addSeparator();
        menuCameras-&gt;addAction(action2_Camera_1);
        menuCameras-&gt;addAction(action2_Camera_2);
        menuCameras-&gt;addAction(action2_Camera_3);
        menuCameras-&gt;addAction(action2_Camera_4);
        menuCameras-&gt;addAction(action2_Camera_5);
        menuCameras-&gt;addAction(action2_Camera_6);

        retranslateUi(CameraClass);
        QObject::connect(actionCamera_Setup, SIGNAL(activated()), CameraClass, SLOT(show()));

        QMetaObject::connectSlotsByName(CameraClass);
    } // setupUi

    void retranslateUi(QMainWindow *CameraClass)
    {
        CameraClass-&gt;setWindowTitle(QApplication::translate("CameraClass", "Camera", 0, QApplication::UnicodeUTF8));
        actionExit-&gt;setText(QApplication::translate("CameraClass", "Exit", 0, QApplication::UnicodeUTF8));
        actionCamera_Setup-&gt;setText(QApplication::translate("CameraClass", "Camera Setup", 0, QApplication::UnicodeUTF8));
        actionFull_Screen-&gt;setText(QApplication::translate("CameraClass", "Full Screen", 0, QApplication::UnicodeUTF8));
        action1_Camera_1-&gt;setText(QApplication::translate("CameraClass", "1 Camera 1", 0, QApplication::UnicodeUTF8));
        action1_Camera_2-&gt;setText(QApplication::translate("CameraClass", "1 Camera 2", 0, QApplication::UnicodeUTF8));
        action1_Camera_3-&gt;setText(QApplication::translate("CameraClass", "1 Camera 3", 0, QApplication::UnicodeUTF8));
        action1_Camera_4-&gt;setText(QApplication::translate("CameraClass", "1 Camera 4", 0, QApplication::UnicodeUTF8));
        action1_Camera_5-&gt;setText(QApplication::translate("CameraClass", "1 Camera 5", 0, QApplication::UnicodeUTF8));
        action1_Camera_6-&gt;setText(QApplication::translate("CameraClass", "1 Camera 6", 0, QApplication::UnicodeUTF8));
        action2_Camera_1-&gt;setText(QApplication::translate("CameraClass", "2 Camera 1", 0, QApplication::UnicodeUTF8));
        action2_Camera_2-&gt;setText(QApplication::translate("CameraClass", "2 Camera 2", 0, QApplication::UnicodeUTF8));
        action2_Camera_3-&gt;setText(QApplication::translate("CameraClass", "2 Camera 3", 0, QApplication::UnicodeUTF8));
        action2_Camera_4-&gt;setText(QApplication::translate("CameraClass", "2 Camera 4", 0, QApplication::UnicodeUTF8));
        action2_Camera_5-&gt;setText(QApplication::translate("CameraClass", "2 Camera 5", 0, QApplication::UnicodeUTF8));
        action2_Camera_6-&gt;setText(QApplication::translate("CameraClass", "2 Camera 6", 0, QApplication::UnicodeUTF8));
        label_CCV-&gt;setText(QApplication::translate("CameraClass", "&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;img src=\":/Camera/Resources/pictures/Camera View.jpg\"/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;", 0, QApplication::UnicodeUTF8));
        menuFile-&gt;setTitle(QApplication::translate("CameraClass", "File", 0, QApplication::UnicodeUTF8));
        menuView-&gt;setTitle(QApplication::translate("CameraClass", "View", 0, QApplication::UnicodeUTF8));
        menuCameras-&gt;setTitle(QApplication::translate("CameraClass", "Cameras...", 0, QApplication::UnicodeUTF8));
    } // retranslateUi

};

namespace Ui {
    class CameraClass: public Ui_CameraClass {};
} // namespace Ui

QT_END_NAMESPACE

#endif // UI_CAMERA_H
</code></pre>
