qt中的connect函数
来源:互联网 发布:华为大数据研发岗累吗 编辑:程序博客网 时间:2024/05/24 06:19
1、connect()函数实现的是信号与槽的关联。
注意:只有QO bject类及其派生的类才能使用信号和槽的机制
2、函数原型
static QMetaObject::Connection connect(const QObject *sender, const char *signal,
const QObject *receiver, const char *member, Qt::ConnectionType = Qt::AutoConnection);
static QMetaObject::Connection connect(const QObject *sender, const QMetaMethod &signal,
const QObject *receiver, const QMetaMethod &method,
Qt::ConnectionType type = Qt::AutoConnection);
inline QMetaObject::Connection connect(const QObject *sender, const char *signal,
const char *member, Qt::ConnectionType type = Qt::AutoConnection) const;
在第一个函数中:第一个参数为发射信号的对象,例如后面的dlg;第二个参数是要发射的信号,例如后面的
SIGNAL(dlgReturn(int));第三个参数是接受信号的对象,例如后面的this,表明是本部件,即Widget,当这个
参数是this时,可以将其省略掉,因为在第三个函数中,该参数默认为this;第四个参数是要执行的槽,例如
后面的SLOT(showValue(int)),也可以指定一个信号,实现信号与信号的关联。
eg:
MyDialog *dlg=new MyDialog(this);//将对话框中的自定义信号与主界面中的自定义槽进行关联connect(dlg,SIGNAL(dlgReturn(int)),this,SLOT(showValue(int)));dlg->show();
注意:
1、对于信号与槽,必须使用SIGNAL()和SLOT()宏,它们将参数转化为const char *类型
2、第四个参数指定的槽声明时必须使用slots关键字。
eg:
private slots://槽的声明
void showValue(int value);
void on_label_linkActivated(const QString &link);
阅读全文
0 0
- qt中的connect函数
- QT中的connect函数
- Qt中的connect函数使用
- Qt Creator中的connect函数
- qt中的connect()函数 信号槽
- 小谈Qt中的connect函数
- Qt connect中的 Lambda
- qt中connect函数探究
- redux中的connect函数
- Qt的槽函数的public,protected,private以及Qt4、5中的connect函数。
- QT QObject::connect函数的学习
- QT QObject::connect函数的学习
- QT 信号与槽 connect函数
- 【Qt开发】深入理解connect函数
- 关于对qt connect函数的理解
- QT中Connect函数 信号槽
- 对QT中connect函数的认识
- Qt connect函数的深入研究
- sklearn-例程--Plotting Cross-Validated Predictions
- redhat6.3安装Keepalived+LVS
- LeetCode之路:237. Delete Node in a Linked List
- java多线程总结(3)
- 马踏棋盘问题
- qt中的connect函数
- JS笔试面试题(后续更新)
- 多线程-生产者消费者问题代码2并解决线程安全问题
- 一个检测特效是否丢失材质的脚本
- 承上的状态机图,又是烂图一副
- Android中<meta-data>的使用
- A
- Qt各种版本下载地址
- php通过ssh连接服务器