user4568872
user4568872

Reputation:

QObject::connect: No such signal(classname)(signalname)(atribure)

I have a problem. All is great when I compile, but slots don't work. After application starts, it outputs QObject::connect: No such signal CMatrix::ReadyToDraw(ww). I tested it, slot DrawFunction() doesn't work. I can't debug because of segmentation fault.

header.h

class CMatrix:public QObject
{
    Q_OBJECT
public:
    int **m_pMatrix;
    const short int m_size=4;
public:
    CMatrix();
    bool checkFields();
    void setField();
signals:
    void ReadyToDraw(CMatrix *ww);
public slots:
    void MoveDown();
    void MoveTop();
    void MoveLeft();
    void MoveRight();
};
class MainWindow : public QWidget
{
    Q_OBJECT
public:
MainWindow(QWidget *parent = 0);
    ~MainWindow();
private slots:
    void DrawFunction(CMatrix *A);
public:
    QPushButton* butTop;
    QList<QLabel*> lblList;
};

main.cpp

#include "header.h"
#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    CMatrix *ww=new CMatrix;
    QObject::connect(w.butTop,SIGNAL(clicked()),ww,SLOT(MoveTop()));
    QObject::connect(ww,SIGNAL(ReadyToDraw(ww)),&w,SLOT(DrawFunction(ww)));
    w.show();


    return a.exec();
}

Upvotes: 1

Views: 548

Answers (1)

aep
aep

Reputation: 816

your signals signature is

ReadyToDraw(CMatrix *)

not

ReadyToDraw(ww)

as connect() needs the type, not the name of the variable.

so change your connect line to:

QObject::connect(ww,SIGNAL(ReadyToDraw(CMatrix *)),&w,SLOT(DrawFunction(CMatrix *)));

Upvotes: 1

Related Questions