一个信号可以绑定多个槽
signalObject* sg1 = new signalObject():slotObject* sl1 = new slotObject();QPushButton* btn = new QPushButton();
connect(sg1, &slotObject::signal1(), sl1, &signalObject::slot1());connect(sg1, &slotObject::signal1(), sl1, &signalObject::slot2());
多个信号可以绑定同一个槽
connect(sg1, &slotObject::signal1(), sl1, &signalObject::slot1());connect(sg1, &slotObject::signal2(), sl1, &signalObject::slot1());connect(btn, QPushButton::clicked, sl1, &signalObject::slot1());
槽函数的参数和信号的参数类型必须一一对应
Signal:void signal1(QString p1, Qstring p2);void signal2(int i1, char c2);
Slot::void slot1(QString p1, Qstring p2);void slot2(int i1, char c2);
singal1 与 slot1 对应, signal2 与 slot2 对应
信号的参数个数可以多余槽函数的参数个数,反之不可以
signal3(int i1, char c2, double d3);slot3(int i1);
signal3 与 slot3 对应