wysota already explained that the program didn't stuck in the exec() call but was executing the eventloop as expected.
However, I don't see the need to have a separate control flow in your lower layer, be it a thread or a child process.
Lets assume you have a class which provides all the methods fr your applications instances.
You can decide at startup if you want to call this methods from slots of a GUI or from a function in hardcoded or script controlled order.
For example lets assume I have a class like this
|
Source code
|
1
2
3
4
5
6
|
class Test
{
public:
void hello() { cout << "hello" << endl; }
void world() { cout << "world" << endl; }
};
|
I could then have a main.cpp that either starts in event mode, allowing to output the text in any order by calling the methods from slots connected to buttons or timers, or in a normal straight control flow, outputting "hello world"
|
Source code
|
1
2
3
4
5
6
7
|
int main(int argc, char** args)
{
if (argc >= 2 && strncmp(args[1], "--gui", 5) == 0)
return startGUI(argc, args);
else
return startNormal(argc, args);
}
|
startNormal would just instantiate Test and call hello() and world(), startGUI would initalize the QApplication and the GUI and so on.
Cheers,
_