Results 1 to 3 of 3

Thread: Redirect printf and update progressbar

  1. #1
    Join Date
    May 2011
    Posts
    20
    Qt products
    Qt4
    Platforms
    Windows

    Default Redirect printf and update progressbar

    hi,
    I'm training a NN with the OpenCV library. For more information's I uncommented the line 917 in the ann_mlp.cpp File:

    printf("%d. E = %g\n", iter/count, E);

    now the output is show in the console output.

    I would like to add a progressbar and redirect the printf-ouput to a QPlainTextField.
    How could I realized that? How could I update the Progressbar without too many changes in the OpenCV Library?

    thx

  2. #2
    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: Redirect printf and update progressbar

    You'd have to somehow substitute STDOUT with your own file descriptor. It's not really Qt related. Once you have that done you can read from the stream and output to a Qt widget.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #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: Redirect printf and update progressbar

    freopen() is the one way to redirect the output to a file. There are a number of suggestions for redirecting to an in-memory buffer/stream here

Similar Threads

  1. How to redirect to a URL in Qt
    By xyz in forum Newbie
    Replies: 8
    Last Post: 30th March 2012, 07:39
  2. Replies: 5
    Last Post: 26th April 2009, 12:50
  3. problem in using printf
    By vishnu5 in forum Qt Programming
    Replies: 1
    Last Post: 15th December 2007, 18:16
  4. printf itself
    By mickey in forum General Programming
    Replies: 14
    Last Post: 29th September 2007, 23:54
  5. Redirect printf to QTextEdit?
    By Randulf in forum Qt Programming
    Replies: 9
    Last Post: 12th October 2006, 14:57

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.