I want to develop a Qt frontend for a program which needs to be usable from a command line as well. First, I thought of solving this with a parameter (if it is set, then UI will be created, else just write on std::out) but I’ve got the feeling that I should separate those components and just create the program for the backend logic ( using plain c++ if possible ). In which case the Qt program can read, and understand the output of the backend. Still if needed the backend could be run alone writing its results on std::out.
What’s the most elegant way to call the backend program from the frontend, without blocking?
My first thought on this was creating a child process and with exec, call the backend, then if the backend is finished, it should signal the frontend and block until frontend is done with reading, where reading could be done through a pipe or something like that.
Is this a good approach? Any other tips for implementation?
Qt has multiple features allowing for asynchronous execution:
My thoughts would be to design the back-end as an API. Specifically, in each component you need an subset of objects (maybe just one) through which all communications with external component goes. Avoid putting too much logic inside the front end and avoid writing the back-end based on visual appearance. It is a bit vague :P.