简介

可以单独设定一个类目用来发送信号。
参考如下代码

code

#ifndef __SINGALFATHER_H__
#define __SINGALFATHER_H__

#include <QObject>
class SingalFather : public QObject {
	Q_OBJECT
public:
	static SingalFather *getInstance();
signals:
	void seditNode(double x, double y, double z, double r);
private:
	static SingalFather *instance;
	SingalFather();
};

#endif

#include "singalFather.h"

SingalFather *SingalFather::instance = nullptr;

SingalFather::SingalFather() : QObject(nullptr) {}


/**************************************************
@brief   : 构造一个新对象 使用单例模式  说实话这个对象没啥用,就是为了承接 更新显示信号的东西
@author  : lee
@input   :none
@output  :none
@time    : none
**************************************************/
SingalFather *SingalFather::getInstance() {
	if (!instance)
		instance = new SingalFather;
	return instance;
}

用到发送信号的地方直接

SingalFather::getInstance()->seditNode(1,1,1,1)

posted on 2020-11-06 21:44  HDU李少帅  阅读(108)  评论(0)    收藏  举报