qt5 槽的使用的简单例子(connect函数)
来源:互联网 发布:mac解压缩软件zip 编辑:程序博客网 时间:2024/06/14 21:00
版本: qt creator 4.0.3 和 qt 5.6.2
简单实例: (并未使用.ui文件, 只用了代码)
test.pro
QT += core guigreaterThan(QT_MAJOR_VERSION, 4): QT += widgetsTARGET = test1TEMPLATE = appSOURCES += main.cpp\ test.cppHEADERS += test.h
test.h
#ifndef FINDDIALOG_H#define FINDDIALOG_H#include <QDialog>class QPushButton;class QDialogButtonBox;class test : public QDialog{ Q_OBJECTpublic: test(QWidget *parent = 0);private slots: void end();private: QPushButton *findButton; QDialogButtonBox *buttonBox;};#endif
test.cpp
#include <QtWidgets>#include "test.h"test::test(QWidget *parent) : QDialog(parent){ findButton = new QPushButton(tr("关闭")); buttonBox = new QDialogButtonBox(Qt::Vertical); buttonBox->addButton(findButton, QDialogButtonBox::ActionRole); connect(findButton, SIGNAL(clicked()), this, SLOT(end())); QGridLayout *mainLayout = new QGridLayout; mainLayout->addWidget(buttonBox, 0, 2, 2, 1); setLayout(mainLayout);}void test::end(){ this->close();}
可以直接运行, 实现功能是: 点击关闭按钮关闭界面
阅读全文
0 0
- qt5 槽的使用的简单例子(connect函数)
- UDP 的Connect函数的例子
- UDP 的Connect函数的例子 .
- qt5 扩展式弹窗的使用例子
- qt5弹框的使用例子
- 使用类型转换函数的简单例子
- 使用函数的一个简单例子
- connect()函数的使用问题
- Android connect函数的使用
- Qt信号槽连接函数connect()的简单使用方法
- oracle connect by函数的简单应用
- 对connect函数的简单理解
- QT5中信号槽之槽函数的使用
- Qt5设计师 的布局管理器的使用例子。
- qt单元测试用法,qt5单元测试例子,qt5单元测试demo,测试你的函数
- 函数指针简单的例子
- VS2015+QT5简单例子(一)
- Linux网络编程connect()函数的使用
- 用两个栈来实现一个队列,完成队列的Push和Pop操作。 队列中的元素为int类型。
- POJ 2240 Floyd的变式
- 大数据预科班6
- kotlin学习day7:null安全
- tomcat 源码学习——准备工作
- qt5 槽的使用的简单例子(connect函数)
- Codeforces 486E. LIS of Sequence
- 微信小程序语音识别探索
- Java使用org.json.jar构造和解析Json数据
- bzoj3715 [PA2014]Lustra 暴力
- 关于Tomcat7启动闪退的解决办法
- 快速排序算法及JAVA实现
- shell基本命令
- TCP/IP分层模型