//1. 使用QT5灵活方式 可指定任意函数为槽函数,信号重载的辨别使用函数指针
    void (subwindow::*fun1)()=&subwindow::mysubsignal;
    void (subwindow::*fun2)(int,QString)=&subwindow::mysubsignal;


    connect(&b,&QPushButton::released,this,&testwidget::myslot);

    connect(&sub,fun1,this,&testwidget::myslot_others);
    connect(&sub,fun2,this,&testwidget::myslot_others2); //出现二义性 信号出现重载 这样需要函数指针

//2. 使用QT4的宏定义方式 

 connect(&sub,SIGNAL(mysubsignal()),this,SLOT(myslot_others()));
    connect(&sub,SIGNAL(mysubsignal(int,QString)),this,SLOT(myslot_others2(int,QString)));  //SIGNAL 不报错 相比于上边的方式 转换为字符串 槽函数得用SLOT 修饰
    
 //上述方式应当注意,若宏SIGNAL中的函数名写错的话编译器不报错, 另外槽函数的声明应使用SLOT修饰

 

扫码关注我们
微信号:SRE实战
拒绝背锅 运筹帷幄

SRE实战 互联网时代守护先锋,助力企业售后服务体系运筹帷幄!一键直达领取阿里云限量特价优惠。