标签:func 连接 href char 比较 成功 tom cli nec
简单剖析一下:connect,可以信号---槽,信号---信号
qt4.x,实际上用的是SIGNAL,SLOT这两个宏
[static] QMetaObject::Connection QObject::connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type = Qt::AutoConnection)
connect返回bool判断是否连接成功
qt5.x
[static] QMetaObject::Connection QObject::connect(const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type = Qt::AutoConnection)
连接过程中connect自行判断
拓展:
若槽实现比较简单可以使用匿名函数lambda实现
QObject::connect(lineEdit, &QLineEdit::textChanged, [=](QString data){
if(!data.isEmpty())
qDebug()<<data<<endl;
});
data这是之前信号发过来的参数
或者不带参数
connect(sendBtn,&QPushButton::clicked, [=](){
qDebug()<<"123"<<endl;}
);
Qt4.x同理。不进行赘述。
标签:func 连接 href char 比较 成功 tom cli nec
原文地址:https://www.cnblogs.com/liuruoqian/p/12905815.html