Results 1 to 5 of 5

Thread: Get contents from output of console app

  1. #1
    Join Date
    May 2018
    Posts
    19
    Thanks
    1
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Get contents from output of console app

    I am writing a console app.
    The console print a few line. And then, I want to get the last line of content output.
    How to do that?
    Example:
    I want to check if the last line contains: "Processing", the console app delete this line and changed "Done"

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Get contents from output of console app

    If you are writing the app, then you are in control of what is written to the console. Why would you need to capture the console output before it is printed and then change it? Just print what should be there.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. #3
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    506
    Thanks
    11
    Thanked 76 Times in 74 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Get contents from output of console app

    Hi, if you want to replace the last line you can use "\r" to go to the beginning of the line before printing something else.
    If you really need to know what you printed last time then store it in a variable. Although I concur with d_stranz: just print the correct line.

    Ginsengelf

  4. #4
    Join Date
    May 2018
    Posts
    19
    Thanks
    1
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Get contents from output of console app

    I also need get content of console output
    I have two way to print:
    qDebug() << "Content";
    QTextStream out(stdout); out <<"Content";
    Which solution is the best for this?

  5. #5
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    506
    Thanks
    11
    Thanked 76 Times in 74 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Get contents from output of console app

    Hi, qDebug won't be visible in release builds, so use the second option.

    Ginsengelf

Similar Threads

  1. Qt Creator Display console output in main window in a sidebar
    By Cupidvogel in forum Qt Tools
    Replies: 4
    Last Post: 30th May 2014, 09:54
  2. console output on windows and ubuntu
    By hannesvdc in forum Qt Programming
    Replies: 2
    Last Post: 11th December 2010, 22:43
  3. No output to console
    By Morea in forum Newbie
    Replies: 6
    Last Post: 1st November 2007, 22:51
  4. Replies: 52
    Last Post: 10th December 2006, 14:32
  5. No console output in Mac OSX using Qt4
    By popoholic in forum Qt Programming
    Replies: 2
    Last Post: 26th September 2006, 01:36

Tags for this Thread

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.