Results 1 to 20 of 53

Thread: How To Redirect The Console Output To A Text Browser/pop Up

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    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: How To Redirect The Console Output To A Text Browser/pop Up

    Quote Originally Posted by deekayt View Post
    my Query is not still answered.Do tell how to circumvent this problem.
    I've already told you: take a look at cjpeg sources and see why it behaves like that, then you can look for a solution.

  2. #2
    Join Date
    May 2006
    Posts
    68
    Thanks
    10
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How To Redirect The Console Output To A Text Browser/pop Up

    how can i have Qprocess -> start() and still read the std out puts.that perhaps may solve the problem.also with Qprocess-> start() how to keep the console screen on instead of closing on its own.Like we useto stop the screen with getchar();

  3. #3
    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: How To Redirect The Console Output To A Text Browser/pop Up

    I've found some cjpeg.exe in the Internet (here) and tested it with Qt 4.1.5 on windows and I had no problem to capture its output.

    So either:
    • you have some other cjpeg.exe that behaves in a different way,
    • your cjpeg is compiled in a weird way,
    • there's something wrong with your program.

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

    deekayt (15th November 2006)

  5. #4
    Join Date
    May 2006
    Posts
    68
    Thanks
    10
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How To Redirect The Console Output To A Text Browser/pop Up

    JACEK
    I must thank you for all the pains you would have taken to look for CJPEG.EXE on the net and then testing it.
    Infact this CJPEG.EXE is from Independent JPEG group ( VERSION 6) .The same program ( VERSION 4) has been modified for data hiding in JPEG images. ANd some more switches have been provided.
    Now instead of just converting a PPM file to JPEG one can add a data file with -steg switch in the JPEG file so formed.( This modification perhaps has not been done in VERSION 6 )

    cjpeg -steg <filename> image.ppm image2.jpg

    is the way it works.
    Now there is a limit to the amount of data one can hide in the JPEG file. When all the filenames are OK and data to be hidden is not exceeding there is no message meaning the thing has worked fine.
    But if the data is too much to be loaded or <filename> or image.ppm is missing then the error message come. Now this happens on the comd prompt and not through my program.
    I couldhave attached the zipped file but it is 2 mb.I am sending it in email. Please have a look at it.You have brought me till here.Thanks

  6. #5
    Join Date
    May 2006
    Posts
    68
    Thanks
    10
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How To Redirect The Console Output To A Text Browser/pop Up

    At Which Email Should I Send 2 Mb Zip File.

  7. #6
    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: How To Redirect The Console Output To A Text Browser/pop Up

    Quote Originally Posted by deekayt View Post
    At Which Email Should I Send 2 Mb Zip File.
    Don't send me your program, instead attach only the cjpeg.exe and I will see if I can make it work.

    There rest is your assignment and you should do it yourself. All I can do is to try to give you some advises.

  8. #7
    Join Date
    May 2006
    Posts
    68
    Thanks
    10
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How To Redirect The Console Output To A Text Browser/pop Up

    I am attaching the cjpeg.exe alongwith
    The command line utility is

    cjpeg -steg <filename1> filename2.ppm filename3.jpg

    where in the filename2.ppm changes to filename3.jpg ( that is it is compressed) and while doing so filename1( could be any type of file) gets embedded in the filename3.jpg.

    Error messages are given when files donot exist or the filename1 is too large to be hidden ( it should be lesser than 10 % of the filename2.ppm size )
    If everything is alright then the data is hidden and no message is generated at all.
    Attached Files Attached Files

  9. #8
    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: How To Redirect The Console Output To A Text Browser/pop Up

    Your cjpeg.exe also works well with my test program (see attachment).
    Attached Files Attached Files

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

    deekayt (19th November 2006)

  11. #9
    Join Date
    May 2006
    Posts
    68
    Thanks
    10
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How To Redirect The Console Output To A Text Browser/pop Up

    Dear JACEK,
    1.Thanks a lot for verifying the CJPEG.EXE.

    2.I am enclosing the extracts of the files main.cpp, steg.h, steg.cpp where cjpeg.exe is used. I have more or less incorporated the things which you have given but it does not work. Do I have to necessarily include “main.moc” .
    3. I believe I need to connect the readyReadStandardOutput() as you have done
    Qt Code:
    1. connect( _proc, SIGNAL( readyReadStandardOutput() ), this, SLOT( read() ) );
    To copy to clipboard, switch view to plain text mode 
    rest most of the things are same.
    Is the second connect also required
    Qt Code:
    1. connect( _proc, SIGNAL( finished(int, QProcess::ExitStatus) ), QCoreApplication::instance(), SLOT( quit() ) );
    To copy to clipboard, switch view to plain text mode 
    Could tell me how to adjust in the existing code.
    I am not able to figure out.
    Please have a look at my abridged code put in the zip file.
    Thanks
    Attached Files Attached Files

  12. #10
    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: How To Redirect The Console Output To A Text Browser/pop Up

    Quote Originally Posted by deekayt View Post
    Do I have to necessarily include “main.moc” .
    No, you need this only if you use Q_OBJECT macro inside a .cpp file.

    Quote Originally Posted by deekayt View Post
    I believe I need to connect the readyReadStandardOutput() as you have done
    This is the usual approach, but reading the output after waitForFinished() also works (at least under Linux).

    Quote Originally Posted by deekayt View Post
    Is the second connect also required
    connect( _proc, SIGNAL( finished(int, QProcess::ExitStatus) ), QCoreApplication::instance(), SLOT( quit() ) );
    No, unless you want to close your application when the process exits.

  13. #11
    Join Date
    May 2006
    Posts
    68
    Thanks
    10
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How To Redirect The Console Output To A Text Browser/pop Up

    As per the main.cpp which you have sent you have made a class Test and and in the constructor you have gone for making a process with the connection of signal and slots.When an Object t of class test is made the process is initiated and the signal is eminated to be taken in by slot read().To remind you your code is down below:-
    Qt Code:
    1. #include <QApplication>
    2. #include <QProcess>
    3. #include <QStringList>
    4. #include <QMessageBox>
    5. #include <QtDebug>
    6. class Test : public QObject
    7. {
    8. Q_OBJECT
    9. public:
    10. Test()
    11. {
    12. _proc = new QProcess( this );
    13. _proc->setReadChannelMode( QProcess::MergedChannels );
    14. connect( _proc, SIGNAL( readyReadStandardOutput() ), this, SLOT( read() ) );
    15. connect( _proc, SIGNAL( finished(int, QProcess::ExitStatus) ), QCoreApplication::instance(), SLOT( quit() ) );
    16. _proc->start( "cjpeg", QStringList() << "aaa" << "bbb" );
    17. }
    18.  
    19. private slots:
    20. void read()
    21. {
    22. QMessageBox::information( 0, "test", _proc->readAllStandardOutput() );
    23. }
    24. private:
    25. QProcess *_proc;
    26. };
    27. int main( int argc, char **argv )
    28. {
    29. QApplication app( argc, argv );
    30. Test t;
    31. return app.exec();
    32. }
    33. #include "main.moc"
    To copy to clipboard, switch view to plain text mode 

    In my existing code I tried the similar thing.First of all I have class steg declared in steg.h but it is public QDialog whereas you have gone for public QObject.Do I have to stick to Public Qobject only.

    Qt Code:
    1. #ifndef STEG_H
    2. #define STEG_H
    3. #include "ui_stegform1.h"
    4. #include <QProcess>
    5. #include <QMessageBox>
    6. class steg : public QDialog
    7. {
    8. Q_OBJECT
    9. public:
    10. steg(QWidget *parent = 0);
    11. QProcess *_proc;
    12. steg(QStringList s2)
    13. {
    14. _proc = new QProcess( this );
    15. _proc->setReadChannelMode( QProcess::MergedChannels );
    16.  
    17. connect( _proc, SIGNAL( readyReadStandardOutput() ), this, SLOT( read()));
    18. // connect( _proc, SIGNAL( finished(int, QProcess::ExitStatus) ), QCoreApplication::instance(), SLOT( quit() ) );
    19. _proc->start(("cjpeg"),s2);
    20. }
    21. private slots:
    22. void stego();
    23. void read()
    24. {
    25. QMessageBox::information( 0, "stego", _proc->readAllStandardOutput());
    26. }
    27. private:
    28. Ui::steg ui;
    29.  
    30. };
    31. #endif
    To copy to clipboard, switch view to plain text mode 
    Thereafter I overloaded the constructor by passing the Qstringlist s2 ( basically to pass arguments to cjpeg). Thereafter in the function stego() written in steg.cpp I
    initiated the object steg t(s2)and called for the function t.read().

    Qt Code:
    1. void steg::stego() /*** THIS MODULE HIDES CODED.TXT ***/
    2. {
    3. if(QFile::exists("coded.txt"))
    4. {
    5. s2 << "-steg" << "coded.txt" << "-q" << ui.compressionspinBox->text() << "cleanimage.ppm" << ui.jpeglineEdit ->text() ;
    6. steg t (s2);
    7. }
    To copy to clipboard, switch view to plain text mode 

    I do get the Qmessage box but no message is there
    It is blank .You also notice that I pass the signal form "stego" to slot read. Is it OK.

    Where is the problem.

  14. #12
    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: How To Redirect The Console Output To A Text Browser/pop Up

    Quote Originally Posted by deekayt View Post
    but it is public QDialog whereas you have gone for public QObject.Do I have to stick to Public Qobject only.
    What is the difference between QObject and QDialog?

    Quote Originally Posted by deekayt View Post
    steg t (s2);
    You create "t" on the stack and it gets destroyed immediately (together with QProcess), because it goes out of scope.
    Instead of creating a new dialog, move the code that creates the process to steg::stego() slot.

Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 09:49
  2. No output to console
    By Morea in forum Newbie
    Replies: 6
    Last Post: 1st November 2007, 22:51
  3. No console output in Mac OSX using Qt4
    By popoholic in forum Qt Programming
    Replies: 2
    Last Post: 26th September 2006, 01:36

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.