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.
Your cjpeg.exe also works well with my test program (see attachment).
deekayt (19th November 2006)
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
rest most of the things are same.Qt Code:
connect( _proc, SIGNAL( readyReadStandardOutput() ), this, SLOT( read() ) );To copy to clipboard, switch view to plain text mode
Is the second connect also required
Could tell me how to adjust in the existing code.Qt Code:
connect( _proc, SIGNAL( finished(int, QProcess::ExitStatus) ), QCoreApplication::instance(), SLOT( quit() ) );To copy to clipboard, switch view to plain text mode
I am not able to figure out.
Please have a look at my abridged code put in the zip file.
Thanks
No, you need this only if you use Q_OBJECT macro inside a .cpp file.
This is the usual approach, but reading the output after waitForFinished() also works (at least under Linux).
No, unless you want to close your application when the process exits.
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:
#include <QApplication> #include <QProcess> #include <QStringList> #include <QMessageBox> #include <QtDebug> { Q_OBJECT public: Test() { connect( _proc, SIGNAL( readyReadStandardOutput() ), this, SLOT( read() ) ); connect( _proc, SIGNAL( finished(int, QProcess::ExitStatus) ), QCoreApplication::instance(), SLOT( quit() ) ); } private slots: void read() { } private: QProcess *_proc; }; int main( int argc, char **argv ) { Test t; return app.exec(); } #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.
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 IQt Code:
#ifndef STEG_H #define STEG_H #include "ui_stegform1.h" #include <QProcess> #include <QMessageBox> { Q_OBJECT public: QProcess *_proc; { 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() { } private: Ui::steg ui; }; #endifTo copy to clipboard, switch view to plain text mode
initiated the object steg t(s2)and called for the function t.read().
Qt Code:
void steg::stego() /*** THIS MODULE HIDES CODED.TXT ***/ { { QStringList s2; s2 << "-steg" << "coded.txt" << "-q" << ui.compressionspinBox->text() << "cleanimage.ppm" << ui.jpeglineEdit ->text() ; steg t (s2); }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.
What is the difference between QObject and QDialog?
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.
It does not work. I have now made steg.h as
Qt Code:
#ifndef STEG_H #define STEG_H #include "ui_stegform1.h" #include <QProcess> #include <QMessageBox> { Q_OBJECT public: QProcess *_proc; // 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() { } private: Ui::steg ui; }; #endifTo copy to clipboard, switch view to plain text mode
and steg.cpp as
I have to have _proc declared in steg.h since I use it in read() also.Qt Code:
void steg::stego() /*** THIS MODULE HIDES CODED.TXT ***/ { { QStringList s2; s2 << "-steg" << "coded.txt" << "-q" << ui.compressionspinBox->text() << "cleanimage.ppm" << ui.jpeglineEdit ->text() ; //QProcess *_proc; connect( _proc, SIGNAL( readyReadStandardOutput() ), this, SLOT( read())); // connect( _proc, SIGNAL( finished(int, QProcess::ExitStatus) ), QCoreApplication::instance(), SLOT( quit() ) ); _proc->start(("cjpeg"),s2); read(); }To copy to clipboard, switch view to plain text mode
I donot know where is the problem
What happens if you add:?Qt Code:
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.
The code now looks like
Qt Code:
QStringList s2; s2 << "-steg" << "coded.txt" << "-q" << ui.compressionspinBox->text() << "cleanimage.ppm" << ui.jpeglineEdit ->text() ; //QProcess *_proc; connect( _proc, SIGNAL( readyReadStandardOutput() ), this, SLOT( read())); // connect( _proc, SIGNAL( finished(int, QProcess::ExitStatus) ), QCoreApplication::instance(), SLOT( quit() ) ); _proc->start(("cjpeg"),s2); //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??
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.
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.
If you look closely you will see, that all error messages are referring to your code. If run qmake again, it should compile.
I tried your code without modification
I should be getting the error since you had supplied invalid arguments "aaa" and "bbb"
_Qt Code:
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
How do you start it?
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:
to the .pro file.CONFIG -= debug_and_release
CONFIG += release
And I've also mentioned the solution.
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.
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.
What happens if you change:
to:Qt Code:
To copy to clipboard, switch view to plain text mode
?Qt Code:
proc->start( QCoreApplication::applicationDirPath() + "/cjpeg.exe", QStringList() << "aaa" << "bbb" );To copy to clipboard, switch view to plain text mode
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:
#include <QApplication> #include <QProcess> #include <QStringList> #include <QMessageBox> #include <QtDebug> { Q_OBJECT public: Test() { connect( _proc, SIGNAL( readyReadStandardOutput() ), this, SLOT( read() ) ); //connect( _proc, SIGNAL( finished(int, QProcess::ExitStatus) ), QCoreApplication::instance(), SLOT( quit() ) ); // _proc->start( "cjpeg", QStringList() << "aaa" << "bbb" ); _proc->start( QCoreApplication::applicationDirPath() + "/cjpeg.exe", QStringList() << "aaa" << "bbb" ); } private slots: void read() { } private: QProcess *_proc; }; int main( int argc, char **argv ) { Test t; return app.exec(); } #include "main.moc"To copy to clipboard, switch view to plain text mode
I was just wondering why you have given
QMQt Code:
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 01:47.
Bookmarks