QT 让信号自由飞翔(骚操作)

简介

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

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)

Hope is a good thing,maybe the best of things,and no good thing ever dies.----------- Andy Dufresne
原文地址:https://www.cnblogs.com/eat-too-much/p/13939118.html