qt为按钮添加点击操作

1.在.h文件当中添加

#include <QPushButton>
class  A
{
    
    
public:
	QPushButton *pushButton;
	
public slots:
	void Event();
} 

2.在cpp文件相应位置添加

this->pushButton=ui->pushButton;//将ui文件上的按钮地址记录过来;
connect(pushButton,SIGNAL(clicked()),this,SLOT(Event()));

3.在cpp中补充EventDo方法

void A::Event()
{
    
    
	qDebug()<<"do event now";
}

猜你喜欢

转载自blog.csdn.net/Fengfgg/article/details/113110280