Part of my code are two C++ classes 'ClassA' and 'ClassB' which are both inherited from QObject.
And in some of its methods ClassB needs to syncronously request data stored in ClassA.
ClassA <----- request data ----- ClassB
Is there Qt API similar to signals/slots which can be used for it?
There are two possible options which I can think of but I am not sure if they are architecturally correct:
1) To define Q_INVOKABLE function in ClassA which would return the needed data as its return value and to call it in ClassB.
But I am not sure if Q_INVOKABLE can be used for purposes other than C++/QML bonding and how to register it properly in other cases.
2) To create regular signal/slot pair in ClassB/ClassA respectively.
signal emitted in ClassB would be used to request the data from ClassA and would have a pointer as its input arg which would point to where store the data. And slot in ClassA would write the data to this pointer.
void ClassA::slot(type *ptr)
{
// write data to ptr
}
void ClassB::signal(type *ptr)