PDA

View Full Version : How to use the QProcess to execute the Browser ?



eric0214
17th November 2009, 06:00
Hello,all


I have a question about use theQProcess

to execute the Browseron the Qt4.5.1for

embedded Linux.



My main program is Buttontest, and when I

press the button in it, it will execute the Browser program whit QProcess. I

use the Qt Demo Browser, and the function is ok on X11.



After that, I try to port this simple

program to my target board(a MIPS embedded board).




When I type the ./Buttontest –qws and ./

browser –qws, it all work fine.



But when I press the button in the

Buttontest program, it does not execute the Browser ,and Qt return the messeage:” Did

not receive a connection event from the qws server .” ?(







How to resolve this problem? Do I need to

modify the code?



I just hope can execute another Qt software

in my main program on the Embedded board.




Sorry about my poor English and thanks for

your Help.

Below is the code

to execute the Browser.






if(sender()->objectName()=="Button1")

{




QProcess process;

process.execute("./browser");

}




Eric Chien

spirit
17th November 2009, 06:41
try one of static functions of QProcess, i.e. QProcess::execute or QProcess::startDetached.
note: read about differences.

Rajeshsan
18th December 2009, 08:27
Hi.....
Plz can i know how to execute program on Qt by QProcess. I'm new to Qt. I need a simple code to execute "ls -l" which should act on CLI(Command line interface). For example if i click on button it should send command "ls -l" to shell. I tried by
mainwindow.h
class QProcess;
Public:
QProcess *proc:

mainwindow.cpp
void Mainwindow::On_button_clicked()
{
proc =new QProcess;
proc->start("ls -l")
}

But it is not working.Can you plz share code with me to execute simple command or to execute a program which on Linux ARM board.

now in CLI i'm executing bu ./program_name -qws

it is working fine but i want run from Qt and writing same lines ./program _name -qws in a line edit of GUI.

Thanks in Advance

yogeshgokul
18th December 2009, 08:49
Use:

bool QDesktopServices::openUrl ( const QUrl & url ) [static] (http://doc.trolltech.com/4.5/qdesktopservices.html#openUrl)

Rajeshsan
18th December 2009, 09:12
Thanks for reply, But i'm using on embedded linux ARM board. I need to just execute a simple code to show "ls -l" or some program ./test -qws. plz can you tell me how it can be achieved

yogeshgokul
18th December 2009, 09:15
Thanks for reply, But i'm using on embedded linux ARM board. I need to just execute a simple code to show "ls -l" or some program ./test -qws. plz can you tell me how it can be achieved
Then why you are asking for browser ?
Ok, you can run a system command using QProcess and redirect its output to any display widget. Now please search this very forum for output redirection.

Rajeshsan
18th December 2009, 09:45
Hello Yogesh sir, I'm working on Windows PC only. by using following commands i got cmd.exe on windows if i click on button.

plz understand what i'm telling. If i click on button cmd.exe got open by
proc=new QProcess;
proc->startDetached("cmd.exe")

okay after getting command window on my PC. I need to send some characters to printed on that commad line like copy etc by using Qt one more button. i searched all options in parameters list of Qt. I didnt get it.Atleast i need to open some file by using same logic if i click a button, it should open some files with defeoned path.

squidge
21st December 2009, 10:06
Rajeshsan, you are confusing people by asking off-topic questions in other peoples threads. Please only ask your questions in your own threads.