Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt app with both Console and GUI components
QtWS25 Last Chance

Qt app with both Console and GUI components

Scheduled Pinned Locked Moved Unsolved General and Desktop
consoleguilibraries
5 Posts 2 Posters 3.9k Views
  • 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.
  • tendimT Offline
    tendimT Offline
    tendim
    wrote on last edited by tendim
    #1

    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
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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

      tendimT 1 Reply Last reply
      0
      • SGaistS SGaist

        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 ?

        tendimT Offline
        tendimT Offline
        tendim
        wrote on last edited by
        #3

        @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
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          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
          1
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            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
            1

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved