Results 1 to 5 of 5

Thread: How to use Windows console in a QT Widget Application?

  1. #1
    Join Date
    Mar 2015
    Posts
    105
    Thanks
    50

    Default How to use Windows console in a QT Widget Application?

    Hi!

    I making a GUI program using QtCreator3.4.0 and i would like to use the console to see some things(i would like to test some lists sizes and other simple things like check the value of a variable in some part of the code, i think is more fast then debug). I'm using Windows 8.1 and MinGw4.9.1.

    I read here i have to add "CONFIG += console" in my .pro file and i did it, i added too "include <iostream> using namespace std;" in my .cpp file but when i try to use "cout << "test";" i get the following error message.

    crt0_c.c:-1: error: undefined reference to `WinMain@16'
    collect2.exe:-1: error: error: ld returned 1 exit status
    How can i do that?

  2. #2
    Join Date
    Apr 2015
    Posts
    7
    Thanked 1 Time in 1 Post
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to use Windows console in a QT Widget Application?

    I use Visual Studio write Qt Application.In vs,just set link--system--subsystem(CONSOLE).

  3. The following user says thank you to feiz for this useful post:

    robgeek (3rd May 2015)

  4. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to use Windows console in a QT Widget Application?

    Assuming that it built correctly before you changed the pro file... Did you rerun qmake after changing the pro file?

  5. The following user says thank you to ChrisW67 for this useful post:

    robgeek (3rd May 2015)

  6. #4
    Join Date
    Mar 2015
    Posts
    105
    Thanks
    50

    Default Re: How to use Windows console in a QT Widget Application?

    Didn't know i had to do this, ChrisW67. I did it, actually i went to sleep and now i started my system and reopened qtcreator is working!

  7. #5
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,311
    Thanks
    314
    Thanked 870 Times in 857 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to use Windows console in a QT Widget Application?

    If you are using Qt Creator, you can simply #include <QDebug> and insert qDebug() statements in your code. When you run the program in debug mode, the debug statement output appears in the Application output window of Qt Creator. No need to mess up your application configuration for something as simple as printing diagnostics at runtime.

Similar Threads

  1. Replies: 8
    Last Post: 23rd August 2012, 19:28
  2. Windows Shutdown Notification of Console Application
    By qtYoda in forum Qt Programming
    Replies: 5
    Last Post: 21st February 2012, 17:50
  3. about console application
    By jirach_gag in forum Qt Programming
    Replies: 2
    Last Post: 5th January 2012, 11:39
  4. Replies: 4
    Last Post: 25th April 2011, 12:43
  5. Replies: 2
    Last Post: 21st November 2010, 18: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
  •  
Qt is a trademark of The Qt Company.