Reputation: 1017
I am trying to write an application with Qt in Netbeans. I am able to open the gnome terminal (in Ubuntu), however I can't seem to get a command to be executed in the terminal once it is open, e.g. to execute the 'ls' command.
Can anyone perhaps help me with some code to execute the ls command in the gnome terminal once it is opened? I am opening the terminal with the following code:
QProcess *proc = new QProcess(this);
proc->start("gnome-terminal");
if (!proc->waitForStarted()) {
}
Upvotes: 0
Views: 1625
Reputation: 10456
Use -e
argument:
proc->start("gnome-terminal -e 'ls'");
To keep the window open, go to Edit > Profile Preferences > Command > When command exits and change to Hold the terminal open.
Upvotes: 1