QT学习-标准信号窗口和槽

信号和槽是QT的核心
信号:短信
槽:接收短信的手机

test01文件下的全部代码:

#include "test01.h"
#include <QPushButton>
test01::test01(QWidget *parent)
	: QMainWindow(parent)
{
    
    
	b1.setParent(this);//指定父对象
	b1.setText("close");
	b1.move(10, 20); 

	b2 = new QPushButton(this);
	b2->setText("open");
	connect(&b1, &QPushButton::pressed, this, &test01::close);
	/*
	&b1:信号发出者,指针类型
	&QPushButton::pressed:处理的信号, &发送者的类名::信号名
	this:信号接受者
	&test01::close:槽函数,信号处理函数 &接收者的类名::槽函数名
	*/
}

test01::~test01()
{
    
    

}

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_51244852/article/details/120110419