QObject::connect not connecting signal to slot

Posted by user1662800 on Stack Overflow See other posts from Stack Overflow or by user1662800
Published on 2012-11-27T22:53:17Z Indexed on 2012/11/27 23:04 UTC
Read the original article Hit count: 231

Filed under:
|
|
|

I am using C++ and Qt in my project and my problem is QObject::connect function doesn't connect signal to a slot. I have the following classes:

class AddCommentDialog : public QDialog
{
    Q_OBJECT

public:
    ...some functions 

signals:
    void snippetAdded();

private slots:
    void on_buttonEkle_clicked();

private:
    Ui::AddCommentDialog *ui;
    QString snippet;
};

A part of my Main window:

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

private slots:
    void commentAddedSlot();
    void variableAddedSlot();
    ...

private:
    AddCommentDialog *addCommentDialog;
    ...
};

Ant the last dialog;

class AddDegiskenDialog : public QDialog
{
    Q_OBJECT

public:
    ...

signals:
    void variableAdded();

private slots:
    void on_buttonEkle_clicked();

private:
    Ui::AddDegiskenDialog *ui;
    ...
};

In the main window constructor i connect signals and slots:

addCommentDialog=new AddCommentDialog();
addDegiskenDialog=new AddDegiskenDialog();

connect(addDegiskenDialog, SIGNAL(variableAdded()), this, SLOT(variableAddedSlot()));
connect(addCommentDialog, SIGNAL(snippetAdded()), this, SLOT(commentAddedSlot()));

The point is my commentAddedSlot is connected to it's signal successfully, but commentAddedSlot is failed. There is the Q_OBJECT macros, no warning such as about no x slot. In addition to this, receivers(SIGNAL(snippetAdded())) gives me 1 but receivers(SIGNAL(variableAdded())) gives me 0 and i used commands qmake -project; qmake and make to fully compile. What am i missing?

© Stack Overflow or respective owner

Related posts about c++

Related posts about qt