Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved Qt app with both Console and GUI components

    General and Desktop
    console gui libraries
    2
    5
    3157
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • tendim
      tendim last edited by tendim

      Hi.

      I am developing a new application, which is to have both a console UI and a GUI for the user. At a high level, I have three folders in my file hierarchy, one with the core code, one with console UI code, and one with GUI code.

      New to Qt, what would be the best way to set this up? Are there any tutorials which handle an app which has multiple front ends? I have only found ones which focus on either console UI, or graphical UI, but not one that gives the option for both. E.g., my pseudo-code in main would be:

      int main (int argc, char **argv)
      {
        if (commandlineswitch=="--ui_console")
        {
          // CLI selected, launch console UI
        }
        elseif (commandlineswitch="--ui_gui")
        {
          // GUI selected, launch Qt GUI
        }
        else
        {
          std::cerr << "no UI specified; quiting.";
          return 1
        }
      }
      

      Any suggestions on how to set this up? Would have one project with three sections? Three projects (one for core code, one for console UI, one for GUI) that interact with each-other?

      Thanks,
      -10d

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi and welcome to devnet,

        Will your GUI use your console application e.g. like mplayer's GUI frontend ? Or will it use the same core components ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        tendim 1 Reply Last reply Reply Quote 0
        • tendim
          tendim @SGaist last edited by

          @SGaist it will not use the console directly. Rather I would have a core library, and both the console and GUI would perform functionality through the core library. So in your example it would use the same core components.

          1 Reply Last reply Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            In that case you can use the subdirs template. Make a library from your common components that you build first and then the other two.

            Something like:

            TEMPLATE = subdirs
            SUBDIRS = myconsoleapp myguiapp corelib
            
            myconsoleapp.depends = corelib
            myguiapp.depends = corelib
            

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply Reply Quote 1
            • SGaist
              SGaist Lifetime Qt Champion last edited by

              By the way, in QApplication's detailed documentation, you have an example of how start an application in "no-gui" mode.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply Reply Quote 1
              • First post
                Last post