Results 1 to 7 of 7

Thread: No output to console

  1. #1
    Join Date
    Feb 2006
    Posts
    209
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default No output to console

    I'm having problem getting output of this simple program in the console in w2k. In Linux, no problem, I get the expected lines. Can anyone find a problem with this? Why isn't there any output?
    Attached Files Attached Files
    • File Type: zip q.zip (1.4 KB, 36 views)

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

    Default Re: No output to console

    Add "CONFIG += console" to your .pro file.

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

    Morea (26th February 2006)

  4. #3
    Join Date
    Feb 2006
    Posts
    209
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: No output to console

    No need to create a QApplication or QCoreApplication?
    Last edited by Morea; 26th February 2006 at 23:13.

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: No output to console

    No. The console is independent of Qt.

  6. The following user says thank you to wysota for this useful post:

    Morea (26th February 2006)

  7. #5
    Join Date
    Feb 2006
    Posts
    209
    Thanks
    13
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: No output to console

    Thank you all! Your patience with all my problems is incredible.

  8. #6

    Default Re: No output to console

    I have a similar program(see below), and I do add "config += console" for qmake. but I can only get the first output but not the second output. Does anyone can help me?

    Mingw 3.4.5 + Windows Vista Home

    Qt Code:
    1. #include <QProcess>
    2. #include <QString>
    3. #include <QByteArray>
    4. #include <QTextStream>
    5. #include <QDebug>
    6.  
    7. int main(int argc, char** argv){
    8. QTextStream out(stdout);
    9. out<<"[result]"<<endl<<flush;
    10. qDebug()<<"debug output"<<endl;
    11.  
    12. p=new QProcess();
    13. p->start("dir");
    14. if (!p->waitForFinished())
    15. return -1;
    16. b=p->readAll();
    17. out<<QString(b)<<endl;
    18. qDebug()<<QString(b);
    19. out<<"[end]"<<endl;
    20. qDebug()<<"debug end";
    21. return 0;
    22. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by jacek; 1st November 2007 at 21:11. Reason: missing [code] tags

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

    Default Re: No output to console

    Quote Originally Posted by zhanxw View Post
    I have a similar program(see below), and I do add "config += console" for qmake. but I can only get the first output but not the second output.
    Probably QProcess::waitForFinished() fails and the execution flow doesn't reach the second part of main(). Create QCoreApplication (or QApplication) instance at the beginning of main().

Similar Threads

  1. How to Compile VTKDesigner2 with Qt?
    By alfredoaal in forum Newbie
    Replies: 0
    Last Post: 5th September 2008, 05:34
  2. Replies: 52
    Last Post: 10th December 2006, 14:32
  3. redirection of standard input and output
    By guestgulkan in forum Qt Programming
    Replies: 2
    Last Post: 15th October 2006, 20:30
  4. No console output in Mac OSX using Qt4
    By popoholic in forum Qt Programming
    Replies: 2
    Last Post: 26th September 2006, 01:36
  5. How to run a console program "silently"?
    By fullmetalcoder in forum Qt Programming
    Replies: 9
    Last Post: 23rd July 2006, 10: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.