PDA

View Full Version : How to Port Q3Process::launch to Qt4 ?



darshan.hardas
15th October 2007, 08:39
While porting code from Qt3 to Qt4, I encounter the following problem.

I create Process object

QProcess m_Process = QProcess(this);

Now there is one statement which needs to be ported:


m_Process->launch(some_Argument);

I have used :

m_Process->execute(some_Argument);

I'm using this, but the process doesn't get launch. :confused:

marcel
15th October 2007, 08:43
Look at the QProcess documentation. There is an example there.
execute() is a static member so you don't need a QProcess instance.

radhika.khandway
15th October 2007, 09:21
Even I am searching an equivalent function to Q3Process::launch.
But i didn't got.
I am porting some code from Qt3 to Qt4.
The Qt3 code is as follows:
m_process = new QProcess(this);

connect(m_process, SIGNAL(processExited()),
this, SLOT(slotPsOutputCompleted()));

m_process->launch(Arg);

I have used finished(int, QProcess::ExitStatus) signal instead of processExited().
But couldn't port launch in Qt4.
Please guide me for the same.

patrik08
18th November 2007, 17:41
Even I am searching an equivalent function to Q3Process::launch.
But i didn't got.
I am porting some code from Qt3 to Qt4.
The Qt3 code is as follows:
m_process = new QProcess(this);

connect(m_process, SIGNAL(processExited()),
this, SLOT(slotPsOutputCompleted()));
m_process->launch(Arg);


Have you found the porting solution without qt3to4?

I found the same problem on convert postscript file to PNG image

QT3 code send and take all data to stdin stdout and never save item to file....



proc = new QProcess();
#if defined(Q_OS_WIN32)
proc->addArgument( "gswin32c" );
#else
proc->addArgument( "gs" );
#endif
proc->addArgument( "-q" );
proc->addArgument( "-dBATCH" );
proc->addArgument( "-dNOPAUSE" );
proc->addArgument( "-sDEVICE=pnggray" );
proc->addArgument( "-sOutputFile=-" );
proc->addArgument( "-" );

writingStdout = true;
/* send postscript code to console */
if ( !proc->launch( psBarcode ) ) {
/* error code */
} else {
readingStdout = true;
while ( readingStdout ) {
qApp->processEvents();
if ( !proc->isRunning() )
writingStdoutFinished(); /* read png data from console ... */
}
}



qt4 code ...



QStringList cmd;
cmd.append(ghosti); /* Ghostscript bin full path */
cmd.append("-dBATCH");
cmd.append("-dNOPAUSE");
cmd.append("-sDEVICE=pnggray");
cmd.append("-sOutputFile="+imageiosFileCache); /* define out file */
cmd.append("-q");
cmd.append(stimeFileCache); /* define in file postscript to transform */
Barcode_Delete( bc ); /* remove barcode gnu */
errprocess = false;
procfinished=false;
if (getGSVersion().size() < 4) {
PaintError(tr("Install Ghostscript."));
return;
}
const QString makepnggreycommand = cmd.join(" ");
proc = new QProcess(this);
connect(proc, SIGNAL(finished(int)),this, SLOT(SlotEndProcess(int)));
proc->start(makepnggreycommand);




QT4 QProcess having .... doc "Processes have two predefined output channels: The standard output channel (stdout) supplies regular console output, and the standard error channel (stderr) ...."

also i suppose if a stdin chanel not exist on QT4 QProcess maybe is not possibel to send postscript code to a chanel... grep QTextStream on site doc QProcess qt4 return Null..
Or ist this mistake , work on qt4 postscript transform without file ?