PDA

View Full Version : how to Qprocess



shrikarcse
27th March 2006, 19:49
1) how to call another c program when i click the button.
2) i generated the source code using uic from an ui file. then tried to use them and something like this
consider x1.h and x1.cpp are the files created
i did
x1.pro
CONFIG+=QT
HEADER=X1.H
SOURCES+=X1.CPP
TARGET=X1

AND THEN TRIED QMAKE.
THEN WHILE MAKE I GOT AN ERROR LIKE VTABLE ERROR
WHAT SHUD I DO

wysota
27th March 2006, 21:34
1) how to call another c program when i click the button.

Use QProcess class.


2) i generated the source code using uic from an ui file. then tried to use them and something like this
AND THEN TRIED QMAKE.
THEN WHILE MAKE I GOT AN ERROR LIKE VTABLE ERROR
WHAT SHUD I DO
1. Don't shout
2. There can be many reasons for that. For example that you put a Q_OBJECT containing class definition and implementation in one file.

shrikarcse
29th March 2006, 16:39
i want to execute a c program when i click a button on the form how shud i do it.
i heard we need to use qprocess for it but did not execute.
here are the steps i carried out
1) i have a button called execute in the form
2) i created a function by using edit slot called runprog( )
in that function i have some thing like this
when i clicked the execute button and said source it asked me to create ui.h ?
then when i said yes
it gave me a function called
runprog()
{
Qprocess *proc=new Qprocess(0);
proc->addArgument("/home/shrikar/hello"); // here hello is the executable
proc->start( )
}
it did not give any results
please help me

jpn
31st March 2006, 13:29
1) Don't double post, please..
2) Use [ code ] tags around posted code blocks
3) What is the expected "result"? Is it a GUI or console app?

shrikarcse
31st March 2006, 14:00
both are there a gui application as well as a console application

Beluvius
31st March 2006, 14:10
What is it you do in the hello program?

If you write something to standard out, it is indeed not printed. The output of the child process is automatically caught in the QProcess, and can be retrieved by the readLineStdOut() function. If you don't read from the process, the output is never shown.

Try writing to a file in hello or read the output from the process. That should convince you the program is running.

jacek
31st March 2006, 14:12
@shrikarcse: Please, don't start multiple threads on the same problem or else...