深入探究connect函数
来源:互联网 发布:php gzip 解压缩 编辑:程序博客网 时间:2024/06/05 21:59
首先我们都知道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函数
- SpringMVC DispatcherServlet重写、自定义拦截器拦截器(一)
- 谈一谈自己对依赖、关联、聚合和组合之间区别的理解
- Android平台Camera实时滤镜实现方法探讨(三)--通过Shader实现YUV转换RBG
- HDU 4857 逃生 && Codeforces 825 E. Minimal Labels 逆向拓扑序+优先队列
- FUNDAMENTAL Unit03 运算符和表达式 、 分支结构
- 深入探究connect函数
- 共性问题
- 迈出从3K到1W的重要一步——掌握设计模式
- Struts2 Validation验证框架错误提示信息的显示位置
- BZOJ 1003 [ZJOI2006] 物流运输
- MySQL 数据类型
- bzoj 2761 [JLOI2011]不重复数字
- 安装单机版zookeeper
- 欢迎使用CSDN-markdown编辑器