Results 1 to 4 of 4

Thread: Writing to the console

  1. #1
    Join Date
    Nov 2011
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Writing to the console

    I have experience programming C++ mainly in plain C++ and VisualC++ environments. Some time ago I switched to Mac (MacBook Pro with OS X Lion) and I started learning Qt4.
    I have been able to write simple programs using the Qt4 GUI interface, compiling them within the Mac "Terminal" using the Bash shell. To execute the program, within Terminal I change to the Directory where the compiled application is and I type the command "open MyApplication.app" where "MyApplication.app" is the name of the program I have created. So far no problems.

    Then I decided to do a non-GUI application writing some text to the console creating the file "MyConsole.cpp" as follows:

    #include <iostream>

    int main()
    {
    std::cout << "console application\n";
    }

    I complied the application (in Terminal) using the normal "qmake -project", "qmake", "make" as I do with my GUI applications.

    Then I do an "ls" command and all the files I expect to see are listed, "Makefile", "MyConsole.cpp", "MyConsole.o", "Qt4Console.app" and "Qt4Console.pro" where "Qt4Console" is the directory where "MyConsole.cpp" resides. In summary nothing different from what I see when I do GUIs.

    Now here is the problem I have:
    When I enter the command (in Terminal) "open Qt4Console.app", nothing happens. Terminal responds printing in the screen the current directory.
    I have tried variations of the code that print to the screen but I see nothing.
    Any Ideas about solving this? Please keep in mind that my knowledge of Terminal Bash is very limited and I am afraid I am missing some configuration, switch, flag, etc. to capture text in the console
    Thank you

  2. #2
    Join Date
    May 2010
    Posts
    19
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Writing to the console

    verify that CONFIG += console is added to your .pro file

  3. #3
    Join Date
    Nov 2011
    Posts
    4
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X

    Default Re: Writing to the console

    When I start the compilation process the first thing I do is run "qmake -project" which produces the "*.pro" file. This file does not have the statement CONFIG += console", so I added it manually (without the quotation marks). Then I did "qmake" and finally "make". Then all the files seem to be in place but opening the *.app" file does nothing but printing to the console the current directory. I wonder if manually adding the CONFIG += console breaks the natural flow of the compilation process. Is there any way to get this statement automatically in the "*.pro" file?

    Thank you for your help.

  4. #4
    Join Date
    May 2010
    Posts
    19
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows Android

    Default Re: Writing to the console

    Do you want to create a console application?
    CONFIG += console is automatically included when you create a "Qt Console Application"

Similar Threads

  1. file not writing
    By sujan.dasmahapatra in forum Qt Programming
    Replies: 2
    Last Post: 25th October 2011, 23:01
  2. writing txt to template
    By terhje in forum Qt Programming
    Replies: 1
    Last Post: 6th June 2011, 14:08
  3. Writing a Qt console application
    By sashoalm in forum Newbie
    Replies: 6
    Last Post: 7th February 2011, 17:42
  4. Need help writing my first Qt app
    By netnut in forum Newbie
    Replies: 4
    Last Post: 16th December 2010, 10:52
  5. Writing Plugins for Qt
    By sarode in forum Qt Programming
    Replies: 4
    Last Post: 29th May 2006, 09:04

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.