I have class A with methods like A1, A2, A3, etc each accepting identical parameters (a quint64 and a Qstring). Class A instantiates an object of class B which contains:
typedef void (*TCallBackFunction)(quint64, QString);
struct SCallBacks {
TCallBackFunction success;
TCallBackFunction failure;
};
QMap<int, SCallBacks> m_commandQueue;
void addToMap(int num, SCallBacks cb) {
m_commandQueue[num] = cb;
}
void doCallBack(int num) {
m_commandQueue[num].success(123,"TEST");
}
In class A I would call:
SCallBack t(1,A1);
b.AddToMap(1000,t);
b.doCallBack(1000);
My questions are:
- Can A pass pointers to A methods, and expect child B to call them?
- Is this the right way for B to call A methods? (Signals and slots would require me to copy large amounts of code everytime I reuse the B class...so hopefully that's not the only way)
- I'm unsure about the syntax to store the pointers to function with parameters, and how to call them - can someone fix the errors in the above?