QT——connect的正确写法

来源:互联网 发布:php linux 编辑:程序博客网 时间:2024/05/16 18:37
    connect(ui->bntShow,//sender 发送者            SIGNAL(clicked(bool)),// signal 信号(事件)            this,// receiver 接受者            SLOT(OnTest(bool))//slot槽(事件处理函数)            );


检查是否写对

1.检查返回值

如果connect失败返回false

bool ret = connect(...)if(!ret)...

2.启动调试,connect失败则有错误信息


connect写对了吗?

1.sender或reciever变量名写错

2.只要写参数类型,不能加参数名字

3.关键字SIGNAL和SLOT要大写

原创粉丝点击