在编译Qt程序的时候出现No such slot ....的错误 有Q_OBJECT
Widget::Widget(QWidget *parent) :
QWidget(parent),
ui(new Ui::Widget)
{
ui->setupUi(this);
this->setWindowFlags(Qt::FramelessWindowHint);//去掉标题栏
QPalette palette1=this->palette();
palette1.setBrush(QPalette::Window,QBrush(QPixmap("./images/background.png")));
this->setPalette(palette1);
this->setAutoFillBackground(true);
//加入背景图片
myCom = new Posix_QextSerialPort("/dev/ttyS0",QextSerialBase::Polling);//定义串口对象,指定串口名和查询模式
this->threadSendMessage =new ThreadSendMessage;
this->threadSendMessage->start();
QObject::connect(threadSendMessage, SIGNAL(send1(QString)),
threadSendMessage, SLOT(sendmotor(QString)));
QObject::connect(threadSendMessage, SIGNAL(send2(QString)),
threadSendMessage, SLOT(sendbuzzer(QString)));
class Widget : public QWidget {
Q_OBJECT
public:
Widget(QWidget *parent = 0);
~Widget();
protected:
void changeEvent(QEvent *e);
public:
Ui::Widget *ui;
Posix_QextSerialPort *myCom;
ThreadSendMessage *threadSendMessage;
QTimer *readTimer;
QTimer *readTimer1;
QTimer *readTimer3;
QTimer *readTimer2;
//int SendMsg();
//void addNum(char key);
public slots:
void sendmotor(QString);
void sendbuzzer(QString);
程序片段在这了 求教各位大侠
Qt
------解决方案--------------------
而且信号接收者应该是this而不是threadSendMessage
------解决方案--------------------
需要看看threadSendMessage的头文件,有没有声明信号和槽呢?
都是在一个类里面没有必要使用信号和槽吧?而且信号也不是Qt提供的,是自己定义的。