QObject::connect: No such signal Dialog::search(const QString &str) in ../test/mainwindow.cpp:54
QObject::connect: (sender name: 'Dialog')
QObject::connect: (receiver name: 'MainWindow')
这个信号是在Dialog中声明的。我new了个diaog实例,为何找不到其信号。
dialog = new Dialog(this);
connect(dialog,SIGNAL(search(const QString &str)),this,SLOT(search(const QString &str)));
dialog->show();
------解决方案--------------------
确保:
(1)声明Q_OBJECT宏
(2)定义信号signals,发送信号emit
(2)连接信号 connect(dialog,SIGNAL(search(const QString &)),this,SLOT(search(const QString &))); 敢不敢去掉方法里面的参数,OK?