深入探究connect函数
来源:互联网 发布:做广告牌的软件 编辑:程序博客网 时间:2024/06/06 01:48
首先我们都知道QObject的connect函数的作用是用来连接信号和槽的。
我们再来具体看看connect函数:
connect(sender, SIGNAL(signal), receiver, SLOT(slot));
sender和receiver是对象指针,signal和slot是转换信号和槽。
请看下面代码的具体实现:
//datherdialog.h
#ifndef FATHERDIALOG_H#define FATHERDIALOG_H#include <QDialog>namespace Ui {class FatherDialog;}class FatherDialog : public QDialog{Q_OBJECTpublic:
explicit FatherDialog(QWidget *parent = 0);~FatherDialog();private slots:void on_pushButton_clicked();void showChildDialog();private:
Ui::FatherDialog *ui;};#endif // FATHERDIALOG_H
//fatherdialog.cpp
#include "fatherdialog.h"#include "ui_fatherdialog.h"#include <QMessageBox>FatherDialog::FatherDialog(QWidget *parent) :QDialog(parent),ui(new Ui::FatherDialog){ui->setupUi(this);QObject::connect(ui->childB, //这里把“点击按钮”这个信号与“展示子窗口”这个槽连接在一起,即点击按钮后立即执行showChildDialog函数&QPushButton::clicked,this,&FatherDialog::showChildDialog);}FatherDialog::~FatherDialog(){delete ui;}void FatherDialog::on_pushButton_clicked(){QMessageBox::information(this,"提示","<font size='26'>请告诉我为什么</font>",QMessageBox::Ok);//这里是pushButton按钮点击后响应的函数,同样把信号和槽连接在了一起,//这里根据在界面操作的不同有可能用到了connect函数,也可能是connectSlotsByName函数}void FatherDialog::showChildDialog(){QDialog * d= new QDialog(this);d->show();
}
阅读全文
0 0
- 深入探究connect函数
- 深入探究connect函数
- 深入探究connect函数
- 深入探究connect函数
- 深入探究connect函数
- 深入探究connect函数
- 深入探究connect函数
- 深入探究connect函数
- 深入探究connect函数
- windows实验4-深入探究connect函数
- 深入探究Connect函数(知识点整合)
- 深入探究CONNECT
- 微型技术博客004-深入探究connect函数
- 探究connect函数
- connect函数的探究
- qt中connect函数探究
- 深入探究内联函数
- 深入探究conncet函数
- AndroidStudio2.0以上进行单元测试详解
- RxJava 和 Retrofit的调用示例
- strlen和mystrlen
- 剑指Offer--我用JAVA做(三)
- 说说 freemarker 的命名空间
- 深入探究connect函数
- Gradle实现不同的applicationId
- Android 自定义View——带进度条按钮
- java面试只是点
- 初学数据库greendao 3.2
- 使用FormData对象提交表单及上传图片
- Java书单(不定期更新)
- 深度学习环境配置方法
- 神奇的Drawable文件夹---背景图篇