Results 1 to 5 of 5

Thread: Switching between console and GUI on startup

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,373
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    Wiki edits
    10

    Default Re: Switching between console and GUI on startup

    How about:

    Qt Code:
    1. #include <QApplication>
    2.  
    3. int main(int argc, char **argv){
    4. bool gui = true;
    5. for(int i=1; i<argc; i++)
    6. if(!strcmp(argv[i], "--console")){
    7. gui = false;
    8. break;
    9. }
    10. QApplication app(argc, argv, gui);
    11. //...
    12. return app.exec();
    13. }
    To copy to clipboard, switch view to plain text mode 

  2. The following 2 users say thank you to wysota for this useful post:

    EricF (9th January 2008), pherthyl (9th January 2008)

  3. #2
    Join Date
    Oct 2007
    Location
    Quebec, Canada
    Posts
    40
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    4

    Default Re: Switching between console and GUI on startup

    I feel so dumb now ... Big RTFM for me lol

  4. #3
    Join Date
    Oct 2007
    Location
    Quebec, Canada
    Posts
    40
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    4

    Default Re: Switching between console and GUI on startup

    I may have felt dumb but it's still not working as expected, application don't output to console but is writing the file. So my question remains ...

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    28
    Thanked 976 Times in 912 Posts

    Default Re: Switching between console and GUI on startup

    IMO the problem might be in windows' subsystems. You are using win32 subsystem now, but console applications use different one. You should be able to find some info about this in MSDN (most likely it's a matter of setting right linker flags).

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
  •  
Qt is a trademark of The Qt Company.