-
How To Redirect The Console Output To A Text Browser/pop Up
I am running an external process ( dos exe file runnable on command prompt) through Q process
I need to capture the error messages and either display them in the text browser ( which is static in my form) or make custom made message (depending on what the exe program has given ) and then display them in the textbrowser/popUP
Earlier I was able to do so in qt3.3.4 on linux with the following code
Code:
system ( "/root/stego/encrypt.sh >& /root/stego/error.txt" );
textBrowser->clear();
textBrowser->setSource( "/root/stego/error.txt") ;
where I was running the command prompt command through a script file ( encrypt.sh in above case) and redirecting the screen output to error .txt and then redirecting it to text browser.
Now in qt 4 ( windows) I am using the Qprocess as under
Code:
void steg::encrypt()
{
char encrypt_comand[]= "-e";
char key_comand[]= "-k=";
s3 << encrypt_comand << ui.datalineEdit->text() << "coded.txt" << ( key_comand + ui.passphraselineEdit->text() );
}
The burp.exe is command prompt command and gives the ok/error messages on the screen ( on console). How to direct the same to a text file.Then compare and show a custom message say in a text browser or I can even resort to pop message( why not?/let me improve with qt 4)
Thanks in advance for the guidance.
-
Re: How To Redirect The Console Output To A Text Browser/pop Up
You can use QProcess::readAllStandardOutput() and QProcess::readAllStandardError() to read the data. QProcess::readyReadStandardError() and QProcess::readyReadStandardOutput () signals will be emitted when the data is available.
Of course you will have to use QProcess instance, instead of QProcess::startDetached().
-
Re: How To Redirect The Console Output To A Text Browser/pop Up
I have tried the following
Code:
void steg::encrypt()
{
char encrypt_comand[]= "-e";
char key_comand[]= "-k=";
s3 << encrypt_comand << ui.datalineEdit->text() << "coded.txt" << ( key_comand + ui.passphraselineEdit->text() );
P
->startDetached
( QString("burp.exe"),s3
);
QString result_all
= P
->readAllStandardOutput
();
//QMessageBox::about(this, tr("JPSTEGO"),tr(result_all.toAscii()));
file.setFileName("showjpegfile.txt");
out << result_all.toAscii();
ui.textEdit->insertPlainText(result_all);
}
First I tried to take the Qstring and display in the message box. Nothing happened . Message box comes up but no message is there. Though burp .exe gets executed and gives msg everytime on the command prompt.
Then I tried to redirect the console output to a file and put in a textedit( not a clean way)but it also didnot work.
I am only sure that burp.exe gets executed sinceI find files encrypted as required.I am also sure that some console output always comes. But after that I am not able to find out the problem.
-
Re: How To Redirect The Console Output To A Text Browser/pop Up
Quote:
Originally Posted by
deekayt
P->startDetached( QString("burp.exe"),s3 );
QString result_all = P->readAllStandardOutput();
I've already told you two times, that QProcess::startDetached() is a static method. There is no sense in invoking it on an object.
Try:
Code:
P->start( "burp.exe", s3 );
P->waitForFinished();
QString result_all
= P
->readAllStandardOutput
();
and make sure that this "burp" thing writes to standard output, not standard error stream.
-
Re: How To Redirect The Console Output To A Text Browser/pop Up
My requirement is to get the console output to the text browser.( Message box and text edit)
I have tried the following code
Code:
void steg::encrypt()
{
char encrypt_comand[]= "-e";
char key_comand[]= "-k=";
s3 << encrypt_comand << ui.datalineEdit->text() << "coded.txt" << ( key_comand + ui.passphraselineEdit->text() );
P
->start
( QString("burp.exe"),s3
);
P->waitForFinished();
QString result_all
= P
->readAllStandardOutput
();
ui.textBrowser->setSource( result_all);
}
But it did not work . Then I tried to write the Qstring result_all to a file and then see the file manually.The file gets created but nothing is written to file. That means nothing is in QString result_ all . Then I tried to see that the Qstring result_all is put in the tetxEdit ( since setText is there and perhaps Url thing might be giving problem in TextBrowser) But that also did not work. Those codes are down below
Code:
file.setFileName("showjpegfile.txt");
out << result_all; //NOTHING HAPPENED
ui.textEdit->textCursor().insertText(result_all); //NOTHING HAPPENED
How can I try to put in the message box
I tried the code below.But it doesnot work.
Code:
tr("<p>The <b>JPSTEGO</b> is a data hiding and extraction software"
"forhiding data while converting image files to JPEG format",
+result_all));
-
Re: How To Redirect The Console Output To A Text Browser/pop Up
Does P->waitForFinished() return true? Does "burb.exe" write data to standard output?
-
Re: How To Redirect The Console Output To A Text Browser/pop Up
While I was awaiting your reply I tinkered with the code and was able to figure out the error.
In fact burp.exe was writing to standard error channel instead of standard output. I then further improved it to merge the channels and the code is as
below
Code:
void steg::encrypt()
{
char encrypt_comand[]= "-e";
char key_comand[]= "-k=";
s3 << encrypt_comand << ui.datalineEdit->text() << "coded.txt" << ( key_comand + ui.passphraselineEdit->text() );
P
->setReadChannelMode
(QProcess::MergedChannels);
P
->start
( QString("burp.exe"),s3
);
P->waitForFinished();
QString result_all
= P
->readAllStandardOutput
();
//QDir::setCurrent("E:");
file.setFileName("encrypt_error.html");
out << result_all;
file.close();
ui.textBrowser->clear();
myurl1
=QUrl::fromLocalFile( "encrypt_error.html" ) ;
ui.textBrowser->setSource(myurl1);
}
1. Now I am able to get whatever is the output to the textBrowser . But I believe there would be better way without getting through the file thing. Could you suggest a better method.
2. Moreover I want to output to textbrowser the messages defined by me after comparing what is the output of these exe processes. Is there a method in QT to compare the message, or look for a string and then make own message or delete a part of the message or append a part from the user side and then get it to the textbrowser.
-
Re: How To Redirect The Console Output To A Text Browser/pop Up
Quote:
Originally Posted by
deekayt
Now I am able to get whatever is the output to the textBrowser . But I believe there would be better way without getting through the file thing. Could you suggest a better method.
QTextEdit::setPlainText() or QTextEdit::setHtml()
Quote:
Originally Posted by
deekayt
Moreover I want to output to textbrowser the messages defined by me after comparing what is the output of these exe processes. Is there a method in QT to compare the message, or look for a string and then make own message or delete a part of the message or append a part from the user side and then get it to the textbrowser.
QRegExp and QString::find()
-
Re: How To Redirect The Console Output To A Text Browser/pop Up
Now I am facing a peculiar problem .
After resolving the issue of burp.exe with the following code
Code:
void steg::encrypt()
{
char encrypt_comand[]= "-e";
char key_comand[]= "-k=";
s3 << encrypt_comand << ui.datalineEdit->text() << "coded.txt" << ( key_comand + ui.passphraselineEdit->text() );
P
->setReadChannelMode
(QProcess::MergedChannels);
P
->start
( QString("burp.exe"),s3
);
P->waitForFinished();
QString result_all
= P
->readAllStandardOutput
();
//QDir::setCurrent("E:");
file.setFileName("encrypt_error.html");
out << result_all;
file.close();
ui.textBrowser->clear();
myurl1
=QUrl::fromLocalFile( "encrypt_error.html" ) ;
ui.textBrowser->setSource(myurl1);
}
I had to use it for another exe program that is cjpeg.exe. I used the following code
Code:
void steg::stego()
{
char steg_comand[]= "-steg";
char q_comand[]= "-q";
s2 << steg_comand << "coded.txt" << q_comand << ui.compressionspinBox->text() << ui.imagelineEdit->text() << ui.jpeglineEdit ->text() ;
P1
->setReadChannelMode
(QProcess::MergedChannels);
P1
->start
( QString("cjpeg.exe"),s2
);
P1->waitForFinished();
QString result_hide
= P1
->readAllStandardOutput
();
//QDir::setCurrent("E:");
file1.setFileName("hide_error.html");
out << result_hide;
file1.close();
myurl2
=QUrl::fromLocalFile( "hide_error.html" ) ;
ui.textBrowser->setSource(myurl2);
}
The above code is suppose to convert a .ppm(image file) to jpeg while hiding a text file in it. If all is ok then no output is thrown on the console else one gets an error message.
I deliberately choose parameters to generate the error message but i get blank hide_error.html(which do get created everytime). cjpeg.exe does work since when all parameters are ok I get the jpeg file made. When I run the cjpeg command on command prompt or through a .bat file i get the messages on the console.
In order to verify the code I just replaced cjpeg.exe with burp.exe and i immediately got the error message of burp in my text browser. I know the problem is with cjpeg.exe.But the same thing is fine on command prompt. In fact it is runing even through this code since i got the desired file ( as output ) . I donot know what is the problem.
Could u tell please me How to debug and resolve??
I have been trying forlast three days, but no luck.
-
Re: How To Redirect The Console Output To A Text Browser/pop Up
Quote:
Originally Posted by
deekayt
I know the problem is with cjpeg.exe.But the same thing is fine on command prompt. In fact it is runing even through this code since i got the desired file ( as output ) . I donot know what is the problem.
Maybe that cjpeg program detects that it wasn't started from the console and sits quietly?
-
Re: How To Redirect The Console Output To A Text Browser/pop Up
Probably that is the problem.I am sure it is not behaving as a normal .exe
I tried to run it through a bat (stego.bat)file in which i wrote the command cjpeg
The code was as
Code:
void steg::stego()
{
/*char steg_comand[]= "-steg";
char q_comand[]= "-q";
QStringList s2;
s2 << steg_comand << "coded.txt" << q_comand << ui.compressionspinBox->text() << ui.imagelineEdit->text() << ui.jpeglineEdit ->text() ;
P1->setReadChannelMode(QProcess::MergedChannels);
P1->start( QString("cjpeg.exe"),s2 ); */
P1
->start
(QString("stego.bat")); OR P1
->startDetached
(QString("stego.bat"));
P1->waitForFinished();
QString result_hide
= P1
->readAllStandardOutput
();
//QDir::setCurrent("E:");
file1.setFileName("hide_error.html");
out << result_hide;
file1.close();
//ui.textBrowser->clear();
myurl2
=QUrl::fromLocalFile( "hide_error.html" ) ;
ui.textBrowser->setSource(myurl2);
}
When I used P1->start(QString("stego.bat)); the dos screen appeared and I found the error message(as it should have come) and then the screen disappeared since I have not put any code to stop that. It means there was output to console as I want it . But it didnot get captured to QString result_all . How can I capture it (but keeping only start()) and then redirect to textbrowser.
when I used P1->startDetached (QString("stego.bat)); as expected no screen appeared and the cjpeg command did not run. And interestingly i get the out put as
C:\Qt\4.1.3\stegform1\release>cjpeg
where "C:\Qt\4.1.3\stegform1\release" is the current directory and cjpeg is thecommand written in stego.bat. If i could simulate "enter" after cjpeg in stego.bat perhaps it would have executed.
Can u suggest a way out. I cannot change cjpeg.exe.
-
Re: How To Redirect The Console Output To A Text Browser/pop Up
If you have access to cjpeg sources, you could check why it behaves like that and maybe you will find a way to fool it.
-
Re: How To Redirect The Console Output To A Text Browser/pop Up
changing cjpeg.exe is out of question
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();
-
Re: How To Redirect The Console Output To A Text Browser/pop Up
Quote:
Originally Posted by
deekayt
changing cjpeg.exe is out of question
I didn't write anything about changing cjpeg.exe.
-
Re: How To Redirect The Console Output To A Text Browser/pop Up
Dear JACEK
my Query is not still answered.Do tell how to circumvent this problem.
That is the last thing left in my project .
I know you can get me out of this.
Thanks
-
Re: How To Redirect The Console Output To A Text Browser/pop Up
Quote:
Originally Posted by
deekayt
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.
-
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();
-
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.
-
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
-
Re: How To Redirect The Console Output To A Text Browser/pop Up
At Which Email Should I Send 2 Mb Zip File.
-
Re: How To Redirect The Console Output To A Text Browser/pop Up
Quote:
Originally Posted by
deekayt
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.
-
1 Attachment(s)
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.
-
1 Attachment(s)
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).
-
1 Attachment(s)
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
Code:
connect( _proc, SIGNAL( readyReadStandardOutput() ), this, SLOT( read() ) );
rest most of the things are same.
Is the second connect also required
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
-
Re: How To Redirect The Console Output To A Text Browser/pop Up
Quote:
Originally Posted by
deekayt
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
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
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.
-
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:-
Code:
#include <QApplication>
#include <QProcess>
#include <QStringList>
#include <QMessageBox>
#include <QtDebug>
{
Q_OBJECT
public:
Test()
{
_proc
->setReadChannelMode
( QProcess::MergedChannels );
connect( _proc, SIGNAL( readyReadStandardOutput() ), this, SLOT( read() ) );
_proc
->start
( "cjpeg",
QStringList() <<
"aaa" <<
"bbb" );
}
private slots:
void read()
{
QMessageBox::information( 0,
"test", _proc
->readAllStandardOutput
() );
}
private:
};
int main( int argc, char **argv )
{
Test t;
return app.exec();
}
#include "main.moc"
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.
Code:
#ifndef STEG_H
#define STEG_H
#include "ui_stegform1.h"
#include <QProcess>
#include <QMessageBox>
{
Q_OBJECT
public:
{
_proc
->setReadChannelMode
( QProcess::MergedChannels );
connect( _proc, SIGNAL( readyReadStandardOutput() ), this, SLOT( read()));
// connect( _proc, SIGNAL( finished(int, QProcess::ExitStatus) ), QCoreApplication::instance(), SLOT( quit() ) );
_proc->start(("cjpeg"),s2);
}
private slots:
void stego();
void read()
{
QMessageBox::information( 0,
"stego", _proc
->readAllStandardOutput
());
}
private:
Ui::steg ui;
};
#endif
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().
Code:
void steg::stego() /*** THIS MODULE HIDES CODED.TXT ***/
{
if(QFile::exists("coded.txt")) {
s2 << "-steg" << "coded.txt" << "-q" << ui.compressionspinBox->text() << "cleanimage.ppm" << ui.jpeglineEdit ->text() ;
steg t (s2);
}
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.
-
Re: How To Redirect The Console Output To A Text Browser/pop Up
Quote:
Originally Posted by
deekayt
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
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.
-
Re: How To Redirect The Console Output To A Text Browser/pop Up
It does not work. I have now made steg.h as
Code:
#ifndef STEG_H
#define STEG_H
#include "ui_stegform1.h"
#include <QProcess>
#include <QMessageBox>
{
Q_OBJECT
public:
// steg(QStringList s2)
//{
// _proc = new QProcess( this );
// _proc->setReadChannelMode( QProcess::MergedChannels );
// connect( _proc, SIGNAL( readyReadStandardOutput() ), this, SLOT( read()));
// connect( _proc, SIGNAL( finished(int, QProcess::ExitStatus) ), QCoreApplication::instance(), SLOT( quit() ) );
// _proc->start(("cjpeg"),s2);
// }
private slots:
void stego();
void read()
{
QMessageBox::information( 0,
"stego", _proc
->readAllStandardOutput
());
}
private:
Ui::steg ui;
};
#endif
and steg.cpp as
Code:
void steg::stego() /*** THIS MODULE HIDES CODED.TXT ***/
{
if(QFile::exists("coded.txt")) {
s2 << "-steg" << "coded.txt" << "-q" << ui.compressionspinBox->text() << "cleanimage.ppm" << ui.jpeglineEdit ->text() ;
//QProcess *_proc;
_proc
->setReadChannelMode
( QProcess::MergedChannels );
connect( _proc, SIGNAL( readyReadStandardOutput() ), this, SLOT( read()));
// connect( _proc, SIGNAL( finished(int, QProcess::ExitStatus) ), QCoreApplication::instance(), SLOT( quit() ) );
_proc->start(("cjpeg"),s2);
read();
}
I have to have _proc declared in steg.h since I use it in read() also.
I donot know where is the problem
-
Re: How To Redirect The Console Output To A Text Browser/pop Up
What happens if you add:
Code:
connect( _proc,
SIGNAL( started
() ),
QApplication::instance(),
SLOT( aboutQt
() ) );
?
P.S. There is no sense in calling read() in stego(), QProcess will send a signal when there is something to read.
-
1 Attachment(s)
Re: How To Redirect The Console Output To A Text Browser/pop Up
The code now looks like
Code:
s2 << "-steg" << "coded.txt" << "-q" << ui.compressionspinBox->text() << "cleanimage.ppm" << ui.jpeglineEdit ->text() ;
//QProcess *_proc;
_proc
->setReadChannelMode
( QProcess::MergedChannels );
connect( _proc, SIGNAL( readyReadStandardOutput() ), this, SLOT( read()));
connect( _proc,
SIGNAL( started
() ),
QApplication::instance(),
SLOT( aboutQt
() ) );
// connect( _proc, SIGNAL( finished(int, QProcess::ExitStatus) ), QCoreApplication::instance(), SLOT( quit() ) );
_proc->start(("cjpeg"),s2);
//read();
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??
-
Re: How To Redirect The Console Output To A Text Browser/pop Up
Quote:
Originally Posted by
deekayt
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?
-
2 Attachment(s)
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.
-
Re: How To Redirect The Console Output To A Text Browser/pop Up
Quote:
Originally Posted by
deekayt
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
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.
-
2 Attachment(s)
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"
_
Code:
proc
->start
( "cjpeg",
QStringList() <<
"aaa" <<
"bbb" );
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
-
Re: How To Redirect The Console Output To A Text Browser/pop Up
Quote:
Originally Posted by
deekayt
The test1 does get compiled but when i run it nothing happens.
How do you start it?
Quote:
Originally Posted by
deekayt
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:
- compile Qt libraries in debug mode,
- use "make -f Makefile.Release",
- add:
Quote:
CONFIG -= debug_and_release
CONFIG += release
to the .pro file.
Quote:
Originally Posted by
deekayt
Secondly you mentioned about the
And I've also mentioned the solution.
-
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.
-
Re: How To Redirect The Console Output To A Text Browser/pop Up
Quote:
Originally Posted by
deekayt
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
I tried runing test1.exe from comd prompt but nothing happens.
How? Is cjpeg.exe in the current directory?
-
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.
-
Re: How To Redirect The Console Output To A Text Browser/pop Up
What happens if you change:
Code:
proc
->start
( "cjpeg",
QStringList() <<
"aaa" <<
"bbb" );
to:
?
-
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
Code:
#include <QApplication>
#include <QProcess>
#include <QStringList>
#include <QMessageBox>
#include <QtDebug>
{
Q_OBJECT
public:
Test()
{
_proc
->setReadChannelMode
( QProcess::MergedChannels );
connect( _proc, SIGNAL( readyReadStandardOutput() ), this, SLOT( read() ) );
//connect( _proc, SIGNAL( finished(int, QProcess::ExitStatus) ), QCoreApplication::instance(), SLOT( quit() ) );
// _proc->start( "cjpeg", QStringList() << "aaa" << "bbb" );
}
private slots:
void read()
{
QMessageBox::information( 0,
"test", _proc
->readAllStandardOutput
() );
}
private:
};
int main( int argc, char **argv )
{
Test t;
return app.exec();
}
#include "main.moc"
I was just wondering why you have given
QM
Code:
QMessageBox::information( 0,
"test", _proc
->readAllStandardOutput
() );
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.
-
Re: How To Redirect The Console Output To A Text Browser/pop Up
Quote:
Originally Posted by
deekayt
I want to know that when you started your exe what message did you get. Can you tellme that.
Exactly the same one that cjpeg.exe outputs to the console when you start it with wrong parameters.
-
1 Attachment(s)
Re: How To Redirect The Console Output To A Text Browser/pop Up
Well
Earlier I was compiling after deleting all the refrences to debug from Makefile.And it was compiling . But as you told I now tried
qmake -project
qmake
make -f Makefile.Release
In the folder test1 I only kept main.cpp as you gave
and I came up with hordes of compilation error.
I am not too sure to sort them out as they refer to libraries
I am enclosing those errors in the error_text_file.txt file attached alongwith.
Can you tellme the way out.
Till now my approach of "compiling after deleting all the refrences to debug from Makefile" was cool.
-
Re: How To Redirect The Console Output To A Text Browser/pop Up
Quote:
Originally Posted by
deekayt
make -f Makefile.Release
Are you sure you did that?
-
1 Attachment(s)
Re: How To Redirect The Console Output To A Text Browser/pop Up
Sorry
But even after using make -f Makefile.Release
I get the same error
The error file is attached
-
Re: How To Redirect The Console Output To A Text Browser/pop Up
It looks like there's something wrong with your MinGW installation. Can you compile any other Qt applications?
-
Re: How To Redirect The Console Output To A Text Browser/pop Up
I also think so
I can compile all others except the one which you gave
In fact I am compiling with cjpeg.exe also but that problem of not being able to catch error messages persists.
I will install again and come back to you.
Thanks
-
1 Attachment(s)
Re: How To Redirect The Console Output To A Text Browser/pop Up
Dear JACEK
I have installed QT again.Now I am ableto compile your main.cpp .
But the test1.exe doesnot give me any error message
Can you send me whatever you compiled and ran on your computer.
The error message expected is attached at cjpeg_error.txt file which I got on command line .
-
Re: How To Redirect The Console Output To A Text Browser/pop Up
Quote:
Originally Posted by
deekayt
But the test1.exe doesnot give me any error message
Connect something to QProcess::started() signal to check if cjpeg.exe starts.
-
Re: How To Redirect The Console Output To A Text Browser/pop Up
Dear JACEK
Please refer to post 31. The program does start succesfully.
Can you send me the exe which incorporated cjpeg.exe.
-
Re: How To Redirect The Console Output To A Text Browser/pop Up
I think I know why it works on my system --- I have "CONFIG += console" in my .pro file. The problem is that this cjpeg.exe appears to be a 16-bit executable. Are you sure you can't recompile it?