Answer the question
In order to leave comments, you need to log in
Is there some C++ notification/signal mechanism similar to Qt?
Good day!
For quite a long time I have been writing in Qt, which provides a very convenient signal-slot mechanism. Tell me, is it possible to write at least something remotely resembling in pure C ++? Without Win API.
Let's say there is a DLL that provides a singleton class. It is necessary that after a call on an instance of this class of a certain function, a certain "signal" is sent, which has defined types of transmitted values.
On Qt it would look like this:
class Singleton : public QObject
{
Q_OBJECT
public:
void function(const QString& arg)
{ emit broadcast(arg); }
signals:
void broadcast(const QString& arg);
}
Answer the question
In order to leave comments, you need to log in
Generally speaking, you are interested in the Observer
design pattern.
A large number of implementations can be invented
* In WinAPI using the message system
* In C using function pointers
* In C ++ using std::function or any other object, interface which is known
* In C++ using boost::signals
* Qt signals/slots
* etc.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question