qt creator 信号与槽 代码实现 (二)
来源:互联网 发布:苹果查询网络 编辑:程序博客网 时间:2024/05/14 23:40
一、通过 go to slot 选项实现
1.单击 “今天”,选择 go to slots
2.在 mianwindow.h 文件下产生了
3.在 mianwindow.cpp 文件产生了
4.我们在 上述文件中添加为如下,也是显示 下一个月的功能
5.我们通过ui 界面设置 “close” 信号槽 功能
6.编译,运行 和 上一篇 一样,实现了相同的功能
***********************************************************************
二.通过 自己代码实现
1.在mianwindow.h中 添加自己
2.在 mainwindow.cpp中实现 gototoday()
3.mainwindow.cpp 的构造函数中添加 connect 连接函数
4. qmake
同样实现一样的功能
1.单击 “今天”,选择 go to slots
2.在 mianwindow.h 文件下产生了
- private slots:
- void on_todayButton_clicked();
3.在 mianwindow.cpp 文件产生了
- void MainWindow::on_todayButton_clicked()
- {
-
- }
4.我们在 上述文件中添加为如下,也是显示 下一个月的功能
- void MainWindow::on_todayButton_clicked()
- {
- ui->calendarWidget->showNextMonth();
- }
6.编译,运行 和 上一篇 一样,实现了相同的功能
***********************************************************************
二.通过 自己代码实现
1.在mianwindow.h中 添加自己
- private:
- Ui::MainWindow *ui;
- private slots:
- void on_todayButton_clicked();
- void gototoday(); //自己添加槽函数
- };
2.在 mainwindow.cpp中实现 gototoday()
- void MainWindow::on_todayButton_clicked()
- {
- // ui->calendarWidget->showNextMonth();
- }
- void MainWindow::gototoday() 实现 gototoday 函数
- {
- ui->calendarWidget->showNextMonth();
- }
3.mainwindow.cpp 的构造函数中添加 connect 连接函数
- MainWindow::MainWindow(QWidget *parent) :
- QMainWindow(parent),
- ui(new Ui::MainWindow)
- {
- ui->setupUi(this); //添加代码 红色
- connect(ui->todayButton,SIGNAL(clicked()),this,SLOT(gototoday()));
- }
4. qmake
同样实现一样的功能
0 0
- qt creator 信号与槽 代码实现 (二)
- Qt creator信号与槽的一种方法实现
- QT Creator 信号与槽(配置连接)
- QT 多线程信号与槽(二)
- QT 多线程信号与槽(二)
- QT 的信号与槽机制介绍(二)
- Qt编程之自定义信号与槽(二)
- Qt Creator和VS2010中添加槽信号_差异与详解
- Qt信号与槽实现原理
- Qt信号与槽实现原理
- Qt 信号与信号,信号与槽
- Qt信号-槽源码解析(二)
- qt学习(二):信号和槽
- 【QT】信号和槽机制(二)
- QT 信号与槽 QT简单加法器的实现
- 【QT】深入qt信号与槽实现原理
- qt 槽与信号
- QT信号与槽
- CreateCompatibleDC理解
- gcc库链接
- iOS适配iphone6和6plus(开启高分辨率)
- 五大常用算法——分治法,动态规划,回溯法,分支界限法,贪心算法
- ios htttp网络请求cookie的读取与写入(NSHTTPCookieStorage)
- qt creator 信号与槽 代码实现 (二)
- linux基础之spi驱动程序理解
- 如何在程序中升高和降低权限
- LINUX系统中断系统学习心得
- 卡尔曼滤波
- Linux下tomcat验证码无法显示的问题
- Redis集群+twemproxy+keepalived的安装指南(3)-keepalived的安装
- Python学习-文件操作
- nc设置全局参数设置