阅读源码可以看到:
#define SIGNAL(a) “1”#a
#define SLOT(a) “2”#a
实际上就是一个常量字符串,Qt在connect中的信号和槽参数实质就是const char *
看下下面这个代码:
void KeyButton::onReponse(const QObject * receiverObj,const QString &recever)
{
connect(this,SIGNAL(pressed(int,QString)),receiverObj,recever.toStdString.c_str());
}
//一个按钮调用
button->onReponse(this, SLOT(onKeyPressed(const int&, const QString&)));