Qt报错:
connect(this->cam,SIGNAL(sendImg(QImage)),this->piclbl,SLOT(revImg(QImage)));
error: no matching function for call to ‘DetectPage::connect(Camera&, const char*, PicLabel*&, const char*)’ connect(this->cam,SIGNAL(sendImg(QImage)),this->piclbl,SLOT(revImg(QImage))); ^
解决方法:
1.忘记加QObject
头文件了
#include <QObject>
类的声明定义里记得再加上Q_OBJECT
2.这里的信号函数的声明原来为
void sendImg(QImage img);
现在改为:
void sendImg(QImage);
改完之后这个报错消失,变成:
error: no matching member function for call to 'connect'
candidate function not viable: no known conversion from 'Camera' to 'const QObject *' for 1st argument; take the address of the argument with &
啊哦,我这个第一个参数cam
不是定义为指针,而connect要求是指针,那我定义成指针就行了.