Results 1 to 3 of 3

Thread: I want run one application with GUI or Console based on commandline

  1. #1

    Question I want run one application with GUI or Console based on commandline

    if "Config += console" is added in the ".pro" file, the GUI application will show a console in background, how I remove this console window?
    or how can I start a console in code without using "Config += console".

    My Sample code is as following.
    Qt Code:
    1. main(int argc, char *argv[])
    2. {
    3. if(argc<=1)
    4. runGUI();
    5. else
    6. runConsole();
    7. }
    To copy to clipboard, switch view to plain text mode 
    any suggestion?
    Last edited by wysota; 30th March 2011 at 09:55. Reason: missing [code] tags

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: I want run one application with GUI or Console based on commandline

    The easiest way according to me:

    1. Create a dll with the core functionality
    2. Create a command line tool using that dll
    3. Create a gui tool using that dll
    4. Create a script that takes a parameter and starts either the command line tool or the gui tool.

  3. #3
    Join Date
    Mar 2010
    Posts
    319
    Thanks
    1
    Thanked 14 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: I want run one application with GUI or Console based on commandline

    I am assuming you are talking about doing that on Windows (since everything works natively on Linux and Mac OS X). If so, tbscope has indeed given you one possible way of achieving what you are after. Personally, I don't like the idea of the script. Instead, I went for a .com and a .exe version of my application. For more information, you might want to check a thread I started on this a couple of months ago: http://www.qtcentre.org/threads/3817...-the-same-time.

Similar Threads

  1. about console application
    By jirach_gag in forum Qt Programming
    Replies: 2
    Last Post: 5th January 2012, 11:39
  2. Replies: 7
    Last Post: 13th September 2011, 13:15
  3. Replies: 2
    Last Post: 21st November 2010, 18:03
  4. QT Console application QTextStream
    By Lis in forum Qt Programming
    Replies: 2
    Last Post: 6th November 2010, 05:18
  5. Exiting a Qt Console Application
    By nbetcher in forum Qt Programming
    Replies: 4
    Last Post: 23rd March 2009, 21:03

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.