Converting a desktop application with a GUI to a console application



  • This might sound a little strange but I'll try nevertheless.
    Imagine a large GUI desktop application build using Qt and now you would want to have parts of the application to be run as a console application or even as a service on windows.
    Clearly the application can be "reconfigured" (eliminate all GUI ) in the source code using the precompiler but I was wondering if there are any best practices on how to solve this ?
    Thank you in advance.



  • Hello,

    Not aware of best practices but looking nearly to the same case.

    How do you plan to communicate betwen background and 'missing' GUI ?

    Using Signal and Process or by threading ?

    Cheers,
    Skylar



  • In our case the communication would be all database based.



  • A few notes:

    If the business logic and the user interface of your application is separated (as it should be :-) ), try building a command line application that links the logic part.

    You can then try to abstract the user operations so that they can be triggered from code. Your UIs (command line and GUI) should trigger the same operations through different ways.

    If your code uses event-driven logic (like asynchronous networking or timers), instantiate a QCoreApplication, start it's event loop, and execute the operations in a slot triggered from main().



  • I complete agree in that a perfect separation of business logic an user interface should make this quite simple but unfortunately this is not the case with "this" application. :-(
    We have gone a different path and simply created a new path that prevents any user interaction to actually stop the application and wait for user input.
    This is not perfect but (at least in our case) solves the problem of running the application in batch mode.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.