the goal that I want to achieve is to emit a signal but delay it some time before it is actually emitted.
My idea for this was something like this:
emitLater(QObject *obj, QEvent *event, int msDelay)
{
QTimer...
connect(timout to obj and event...
start timer with msDelay...
//maybe I might need a public timer of some sort but the idea is clear
}
So this approach failed with the QEvent parameter because Signals could not be converted to QEvents.
I tried calling with std::bind in a couple of variations but I couldn't get it to work:
//the call
std::function<void(void)> signal = std::bind(&CustomPushButton_Header::clicked, &uiWindow->btnHeader_left); //just a random button to connect a valid signal
emitLater(signal, 2000);
//the function
emitLater(std::function<void(void)>, int msDelay)
{
qDebug() << "hi";
}
I would appreciate a solution that works for all Objects and all Signals... maybe only the part which does call the function. I think the delay will turn out easy.
Or you have a different and even easier approach. That would be nice.
some sources I looked in: