Page 2 of 3 FirstFirst 123 LastLast
Results 21 to 40 of 53

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

  1. #21
    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.

  2. #22
    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

  3. #23
    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

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

    deekayt (19th November 2006)

  5. #24
    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

  6. #25
    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.

  7. #26
    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.

  8. #27
    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.

  9. #28
    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

    It does not work. I have now made steg.h as
    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. // connect( _proc, SIGNAL( readyReadStandardOutput() ), this, SLOT( read()));
    17. // connect( _proc, SIGNAL( finished(int, QProcess::ExitStatus) ), QCoreApplication::instance(), SLOT( quit() ) );
    18. // _proc->start(("cjpeg"),s2);
    19. // }
    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. #endif
    To copy to clipboard, switch view to plain text mode 

    and steg.cpp as

    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. //QProcess *_proc;
    7. _proc = new QProcess( this );
    8. _proc->setReadChannelMode( QProcess::MergedChannels );
    9.  
    10. connect( _proc, SIGNAL( readyReadStandardOutput() ), this, SLOT( read()));
    11. // connect( _proc, SIGNAL( finished(int, QProcess::ExitStatus) ), QCoreApplication::instance(), SLOT( quit() ) );
    12. _proc->start(("cjpeg"),s2);
    13. read();
    14. }
    To copy to clipboard, switch view to plain text mode 
    I have to have _proc declared in steg.h since I use it in read() also.
    I donot know where is the problem

  10. #29
    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

    What happens if you add:
    Qt Code:
    1. connect( _proc, SIGNAL( started() ), QApplication::instance(), SLOT( aboutQt() ) );
    To copy to clipboard, switch view to plain text mode 
    ?

    P.S. There is no sense in calling read() in stego(), QProcess will send a signal when there is something to read.

  11. #30
    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

    The code now looks like
    Qt Code:
    1. s2 << "-steg" << "coded.txt" << "-q" << ui.compressionspinBox->text() << "cleanimage.ppm" << ui.jpeglineEdit ->text() ;
    2. //QProcess *_proc;
    3. _proc = new QProcess( this );
    4. _proc->setReadChannelMode( QProcess::MergedChannels );
    5.  
    6. connect( _proc, SIGNAL( readyReadStandardOutput() ), this, SLOT( read()));
    7. connect( _proc, SIGNAL( started() ), QApplication::instance(), SLOT( aboutQt() ) );
    8.  
    9. // connect( _proc, SIGNAL( finished(int, QProcess::ExitStatus) ), QCoreApplication::instance(), SLOT( quit() ) );
    10. _proc->start(("cjpeg"),s2);
    11.  
    12. //read();
    To copy to clipboard, switch view to plain text mode 


    Now I get the About QT inboth the case that is when there would be error message and when there is no error message.
    I know that the program has worked fine ( data has been succesfully hidden ) after seeing the concerned file and classicaly speaking noerroror otherwise any message is not given on thecommand console hence nothing should come in the message pop also.But The About QT screen does come everytime.
    The screen snapshot is attached as zip.
    What do you say??
    Attached Files Attached Files

  12. #31
    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
    Now I get the About QT inboth the case that is when there would be error message and when there is no error message.
    This means that the program was started successfully. Maybe you kill it immediately? Does my test program work on your system?

  13. #32
    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

    I have tried to run the main.cpp but could not.
    How did you run it .
    I understand that I should have some form ( Q Dialog) and then on click of button the object should be made
    thus runing the cjpeg.exe,since you had incorporated in the constructor only.
    The error which I got while doing MAKE is in the erro_text_file.txt attached alongwith.
    The code is at the test.zip file.
    Attached Files Attached Files

  14. #33
    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
    I have tried to run the main.cpp but could not.
    How did you run it .
    My program, without any modifications, should compile without any problems. In fact it's a self contained example which verifies that cjpeg.exe output can be captured --- it doesn't need any modifications to run.

    Quote Originally Posted by deekayt View Post
    The error which I got while doing MAKE is in the erro_text_file.txt attached
    If you look closely you will see, that all error messages are referring to your code. If run qmake again, it should compile.

  15. #34
    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 tried your code without modification
    I should be getting the error since you had supplied invalid arguments "aaa" and "bbb"

    _
    Qt Code:
    1. proc->start( "cjpeg", QStringList() << "aaa" << "bbb" );
    To copy to clipboard, switch view to plain text mode 

    and one should be getting the message box with the error captured.
    The test1 does get compiled but when i run it nothing happens.It does get started which I see in the process runing in the Task Manager window of the operating system.
    but that's all.No message at all.
    I am attaching the whole folder which I compiled.
    You will notice that I have edited makefile since I donot want any references to debug . Because when I make with the unedited makefile I get the error as captured in error_text1_file.txt.I did not want to repair the QT make thing hence this shortcut of first deleting all refernces to debug in makefile and then making the makefile.
    Is it because of this shortcut that I am not getting the right thing from your main.cpp or is it something else.

    Secondly you mentioned about the

    "If you look closely you will see, that all error messages are referring to your code."

    how to get this vtable error corrected
    Attached Files Attached Files

  16. #35
    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
    The test1 does get compiled but when i run it nothing happens.
    How do you start it?

    Quote Originally Posted by deekayt View Post
    You will notice that I have edited makefile since I donot want any references to debug .
    There is no need to edit automatically generated files. You have three possibilities:
    1. compile Qt libraries in debug mode,
    2. use "make -f Makefile.Release",
    3. add:
      CONFIG -= debug_and_release
      CONFIG += release
      to the .pro file.


    Quote Originally Posted by deekayt View Post
    Secondly you mentioned about the
    And I've also mentioned the solution.

  17. #36
    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 am I suppose to start the test1.exe.
    It is there in the release folder
    I just double click hoping that message box with error will come but nothing happens.
    I tried runing test1.exe from comd prompt but nothing happens.
    I am still stuck.

  18. #37
    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
    I just double click hoping that message box with error will come but nothing happens.
    If you start the program by double-clicking on it, the current directiry will be set to your desktop (AFAIR), but the program expects that cjpeg.exe will be in the current directory.

    Quote Originally Posted by deekayt View Post
    I tried runing test1.exe from comd prompt but nothing happens.
    How? Is cjpeg.exe in the current directory?

  19. #38
    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

    Once the test1.exe is made in the release directory of test1 folder I copy cjpeg.exe there with all other files which are required to be used . I have been doing the same for all other programs.After that either one double clicks the test1.exe after navigating to release folder or one can copy a shortcut to the desktop ( both work).I am sure that is not the problem.

  20. #39
    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

    What happens if you change:
    Qt Code:
    1. proc->start( "cjpeg", QStringList() << "aaa" << "bbb" );
    To copy to clipboard, switch view to plain text mode 
    to:
    Qt Code:
    1. proc->start( QCoreApplication::applicationDirPath() + "/cjpeg.exe", QStringList() << "aaa" << "bbb" );
    To copy to clipboard, switch view to plain text mode 
    ?

  21. #40
    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

    It is till the same
    When I see in the task manager test1.exe is runing but visually there is nothing.main.cpp looks as below

    Qt Code:
    1. #include <QApplication>
    2. #include <QProcess>
    3. #include <QStringList>
    4. #include <QMessageBox>
    5. #include <QtDebug>
    6.  
    7. class Test : public QObject
    8. {
    9. Q_OBJECT
    10. public:
    11. Test()
    12. {
    13. _proc = new QProcess( this );
    14. _proc->setReadChannelMode( QProcess::MergedChannels );
    15.  
    16. connect( _proc, SIGNAL( readyReadStandardOutput() ), this, SLOT( read() ) );
    17. //connect( _proc, SIGNAL( finished(int, QProcess::ExitStatus) ), QCoreApplication::instance(), SLOT( quit() ) );
    18. // _proc->start( "cjpeg", QStringList() << "aaa" << "bbb" );
    19. _proc->start( QCoreApplication::applicationDirPath() + "/cjpeg.exe", QStringList() << "aaa" << "bbb" );
    20. }
    21. private slots:
    22. void read()
    23. {
    24. QMessageBox::information( 0, "test", _proc->readAllStandardOutput() );
    25. }
    26.  
    27. private:
    28. QProcess *_proc;
    29. };
    30. int main( int argc, char **argv )
    31. {
    32. QApplication app( argc, argv );
    33. Test t;
    34. return app.exec();
    35. }
    36. #include "main.moc"
    To copy to clipboard, switch view to plain text mode 

    I was just wondering why you have given
    QM
    Qt Code:
    1. QMessageBox::information( 0, "test", _proc->readAllStandardOutput() );
    To copy to clipboard, switch view to plain text mode 

    should it not be "Test".Though I changed to that too but still no result.
    I want to know that when you started your exe what message did you get. Can you tellme that.
    Last edited by deekayt; 5th December 2006 at 02:47.

Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 10:49
  2. No output to console
    By Morea in forum Newbie
    Replies: 6
    Last Post: 1st November 2007, 23:51
  3. No console output in Mac OSX using Qt4
    By popoholic in forum Qt Programming
    Replies: 2
    Last Post: 26th September 2006, 02: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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.