I am writing a console application in Qt that maintains a UDP and some TCP connections. The user is occasionally asked to confirm some information before the application continues its regular outgoing messages. However, the way I currently wait for that user input is not functioning the way I need it to.
For now I'm just using this "simple" construct:
std::cout << "Press Enter to continue...":
std::cin.get();
When writing this I knew it would not really work and was gonna have to be replaced, but I do not know how. While it does pause the further sending of messages, it seemingly pauses the entire program, including the Qt event loop. In turn, that causes all TCP connections to be dropped by the peers, as they don't recieve any answers and will assume the connection is to be closed. UDP datagrams can not be handled either.
So I'm trying to find a way that is following Qt's event-based setup. Alternatively I was considering running this on another thread, though I would like to use a few threads as possible, as the hardware this app is running on is very limited in it's capabilities.
Edit: Thanks for the answers, I went with the base for eyllanesc's answer in the linked question at gist.github.com/gjorquera/2576569 , it seems to be working fine.