Why not declare a signals into your singleton header and call it directly?

MySingleton.h

class MySingleton
{
signals:
   void MySignals();
};

myOtherCode.cpp

Q_EMIT  MySingleton::Instance()->MySignals();


-----Original Message-----
From: Interest <interest-boun...@qt-project.org> On Behalf Of Jason H
Sent: November 13, 2019 11:28 AM
To: interestqt-project.org <interest@qt-project.org>
Subject: [Interest] Most simple emit from singleton?

I've stumbled across a paradigm that I am starting to use frequently where I 
have a singleton, and I want it to emit something when I tell it to.

So I've been providing a function and doing: 
MySingleton::instance()->emitMySignal();

Where:
void MySingleton::emitMySignal() {
    emit mySignal();
}

But this seems "silly". Is there a better way to do this? Ideally I'd like to 
skip creating the function and do something like:

MySingleton::instance()->emit MySignal(); or emit 
MySingleton::instance()->MySignal();


There may still be a better way?

Thoughts?

Thanks!

_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest
_______________________________________________
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest

Reply via email to