Object::connect: No such slot QApplication::foo
-
wrote on 17 Mar 2012, 13:51 last edited by
Hello all,
I am writing an application, and I have ran into a strange problem. (At least it is trange for me.) I have done the similar trick in many times in this application and always went fine. The problem is possibly with me, but I could not solved it for a while, so I would like to ask you to review it. Rebuilding was also tried out.
So I have a class:
@#ifndef EGGFINDER_H
#define EGGFINDER_H#include <QObject>
#include "mapitems.h"
#include "settings.h"class EggFinder : public QObject
{
Q_OBJECT
public:
EggFinder(QObject *parent = 0);private:
QList<PyramidItem*> m_pyramids;
void addPyramid(PyramidItem p) {m_pyramids.append(p);}
void checkPyramid(PyramidItem);
QImage *m_currentImage;signals:
public slots:
void foo(double a, double b);
void newImageReceieved(QImage*);
};#endif // EGGFINDER_H
@An the implementation:
@#include "eggfinder.h"
#include <QImage>
#include <QPainter>
#include <QDebug>EggFinder::EggFinder(QObject *parent) :
QObject(parent)
{
}void EggFinder::checkPyramid(PyramidItem *pyramid)
{
QImage pyramidImage(pyramid->boundingRect().size().toSize(), QImage::Format_ARGB32);
pyramidImage = m_currentImage->copy(pyramid->boundingRect().toRect());
pyramidImage.save("out.png");
}void EggFinder::foo(double a, double b)
{
qWarning() << a << b;
}void EggFinder::newImageReceieved(QImage* img)
{
m_currentImage = img;
foreach (PyramidItem *pyramid, m_pyramids) {
checkPyramid(pyramid);
break;
}
}@I creating an instance in my MainWindow from it:
@m_eggFinder = new EggFinder(this);@
And here is where I am trying to connect to the object's slots:
@
void MainWindow::imageGrabberChanged(QImageGrabber ng)
{
currentGrabber = ng;
disconnect(ui->graphicsViewMap, SLOT(newImageReceieved(QImage)));
disconnect(m_imgProc, SLOT(newImageReceieved(QImage*)));
disconnect(m_eggFinder, SLOT(newImageReceieved(QImage*))); // this is row 356
connect(ng, SIGNAL(newImageGrabbed(QImage*)), ui->graphicsViewMap, SLOT(newImageReceieved(QImage*)));
connect(ng, SIGNAL(newImageGrabbed(QImage*)), m_imgProc, SLOT(newImageReceieved(QImage*)));
connect(ng, SIGNAL(newFPSCalculated(double,double)), this, SLOT(newFPSCalculated(double, double)));
connect(ng, SIGNAL(newImageGrabbed(QImage*)), m_eggFinder, SLOT(newImageReceieved(QImage*))); // this is line 360
connect(ng, SIGNAL(newFPSCalculated(double,double)), m_eggFinder, SLOT(foo(double,double))); // and this is 361
}@An in the command line output it says the following, and of course he connections did not made:
@Object::disconnect: No such slot QApplication::newImageReceieved(QImage*) in src/mainwindow.cpp:356
Object::disconnect: (sender name: 'MainWindow')
Object::disconnect: (receiver name: 'egger_controller')
Object::connect: No such slot QApplication::newImageReceieved(QImage*) in src/mainwindow.cpp:360
Object::connect: (receiver name: 'egger_controller')
Object::connect: No such slot QApplication::foo(double, double) in src/mainwindow.cpp:361
Object::connect: (receiver name: 'egger_controller')@The m_imgProc is similarly declared, implemented as my EggFinder class, and it is working.
-
wrote on 17 Mar 2012, 14:11 last edited by
show me the line 356,360 and 361 of code .
-
wrote on 17 Mar 2012, 16:13 last edited by
Check the code snipplet below the line:
bq. And here is where I am trying to connect to the object’s slots:
I have marked the problematic lines.
-
wrote on 17 Mar 2012, 16:32 last edited by
What is egger_controller? Are you sure m_eggFinder is the type you think it is?
-
wrote on 17 Mar 2012, 16:40 last edited by
The egger_controller is the name of my application.
Yes the m_eggfinder is declared in this way:@ EggFinder *m_eggFinder;@
-
wrote on 17 Mar 2012, 17:45 last edited by
Wahhh. Finally I have figured out what caused the problem.
The imageGrabberChanged method gets called before the m_eggFinder instance created.
I have no idea why did not caused SIGSEV ever.Thank you very much for your help!
5/6