@jamat13
Do not use signals/slots for either receiving an immediate reply from any attached slot(s) nor for "waiting" for something to happen as a consequence. That is not what they are intended for --- they are a "notify and continue" paradigm.
If you want a "response" instead either use a direct function call or in the signaller emit the signal, save whatever state is necessary and continue to the Qt event loop, while the slot emits another signal when it is finished which the originally signalling side acts on in its own slot when it arrives. Use a QTimer at the signalling side if you need to know that the slot has not "replied" within a period of time.
answered = false;
emit action ("toolbar", "1whatpage");
QElapsedTimer timer;
for (timer.start (); !timer.hasExpired (2000); ) {
if (answered == true) {
*dbg << "answered " << timer.elapsed () << "ms page " << page[1] << "\n"; dbg->flush ();
answered = false;
break;
}
Your loop is very "busy": it burns your CPU and completely blocks the thread it is in. Since it does not enter the Qt event loop it does not allow normal processing to continue. Behaviour of your code probably depends on whether attached slot(s) run in the same thread or a different one.