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. Hybrid application with GUI or console user interface
QtWS25 Last Chance

Hybrid application with GUI or console user interface

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 8.1k 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.
  • S Offline
    S Offline
    s.frings
    wrote on last edited by
    #1

    Hello,
    I like to develop a QT application that can be used both with console or with GUI interface, whatever the user wants. To switch between both option, I plan to provide a command-line argument.

    My problem is, that the application always opens a console window, when the project file contains the option
    @CONFIG += console@
    but I do not want to see a console window in GUI mode. On the other hand, when I disable that option, then the application does not write anything to stdout and stderr, even when I start it from a cmd shell.

    How can I show and hide the console window at runtime instead of using the project file config?

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DenisKormalev
      wrote on last edited by
      #2

      Not a direct answer to your question, but another look at you problem. Maybe better is to divide program at three parts:

      backend (something which contains all logic but does not contain any interface at all)

      GUI frontend

      console frontend

      Frontend and backend can interact via any IPC you want. In this case you will not have one executable with arguments, but you will have two executables. Maybe it is also appliable for you?

      1 Reply Last reply
      0
      • S Offline
        S Offline
        s.frings
        wrote on last edited by
        #3

        Yes, splitting the application into backend and two different frontends is an option but only if my idea is not possible.

        The user should be able to start the program as a windows service, a linux daemon or in interactive GUI mode without needing to install anything (just unpack a ZIP file and click on the executable file).

        1 Reply Last reply
        0
        • D Offline
          D Offline
          DenisKormalev
          wrote on last edited by
          #4

          Then maybe add one more part - loader? Which will ask user what he wants and will run needed frontend.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            s.frings
            wrote on last edited by
            #5

            That's what gimp obviously does. I checked out a lot of other hybrid programs and they all provide different binaries for GUI and console mode plus a wrapper binary. So that's possibly the solution that I should also use.

            1 Reply Last reply
            0
            • L Offline
              L Offline
              lyuts
              wrote on last edited by
              #6

              Wrapper binary sounds like busybox. Tons of symlinks on the single binary which looks at @argv[0]@. Maybe this is a solution for you, but I would separate it into backend and GUI/CLI frontend as Denis suggested.

              I'm a rebel in the S.D.G.

              1 Reply Last reply
              0

              • Login

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