How to pass a signal or slot (member-function, new syntax in Qt 5) as a parameter to a function, and then call connect ?
eg. I want to write a function that is waiting for a signal.
Note : it does not compile - PointerToMemberFunction is my question.
bool waitForSignal(const QObject* sender, PointerToMemberFunction??? signal, int timeOut = 5000) { if (sender == nullptr) return true; bool isTimeOut = false; QEventLoop loop; QTimer timer; timer.setSingleShot(true); QObject::connect(&timer, &QTimer::timeout, [&loop, &isTimeOut]() { loop.quit(); isTimeOut = true; }); timer.start(timeOut); QObject::connect(sender, signal, &loop, &QEventLoop::quit); loop.exec(); timer.stop(); return !isTimeOut; }
Is there a way to pass a list of signals to this function for a connection?
source share