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

  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

    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

  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

    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.

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

    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

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

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

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

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

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

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

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

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

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.