Dear visitor, welcome to QtForum.org.
If this is your first visit here, please read the Help. It explains in detail how this page works.
To use all features of this page, you should consider registering.
Please use the registration form, to register here or read more information about the registration process.
If you are already registered, please login here.
about command run
QProcess don't run whole command.
example:
|
Source code
|
1
2
3
4
5
|
QProcess *process=new QProcess(this);
process->addArgument("cd");
process->addArgument("..");
"cd /root" , "clear" .....
How do I?
|
Thank you!!!
QProcess doesn't emulate a complete shell. For changing the working dir, use QProcess::setWorkingDirectory() and then call clear.
However, I don't see how this could make sense. clear clears the screen of the current terminal, since you don't have one, there's nothing to be cleared.
Michael.
I don't understand.
Do you give some code?
Thank you!!!
I would have to know what you want to achieve to be able to give you example code.
Michael.
I want use process run "cd"command
Thank you!!!
if you are working in a microsoft environment you could use "cmd.exe -c cd path/to/your/files"
Documentation is like sex: when it is good, it is very, very good. And when it is bad, it is better than nothing. - Dick Brandon
I working linux (Fedora core)
Thank you!!!
use QDir;
QDir dir;
const QString path = "Some Path";
dir.setCurrent(path);
Cross platform.
|
Source code
|
1
2
3
|
QDir dir;
const QString path = "/";
dir.setCurrent(path);
|
But is not use.
I think know cd directory.
thank you for me help.
This post has been edited 2 times, last edit by "Worm" (Mar 23rd 2005, 3:18pm)
What do you need to change directory for?
Kandalf
There's no place like ~
AFAIK there is no such program as "cd" -- it is implemented by shells (try calling "which cd" and you'll see that you don't have such tool in your path) and thus you can't call it via QProcess (well... you can, but it wouldn't have any effect on anything as the shell would end immediately). To change directories use QDir or QApplication methods.
I think you may be able to use system("cd /");
Having the ability to read and understand seems to be luxury.
In my first post I told you that you can use
void QProcess::setWorkingDirectory ( const QDir & dir ) [virtual]
Sets dir as the working directory for processes. This does not affect running processes; only processes that are started afterwards are affected.
Setting the working directory is especially useful for processes that try to access files with relative paths.
See also workingDirectory() and start().
if you want to execute your command in a certain directory. Running "cd <whatever>" in a QProcess is just useless as it *isn't* a complete shell.
Read what we say or fuck off.
Michael.
I try isn't ok
do you give whole code?
thank you.
regarding Qprocess and working directory
Hi,
I am also facing the relative path problems with Qprocess.I tried setWorking Directory in the following way:
I have the following folder heirarchy:
/Version/Temp and its in this Temp directory that I want to run my process.
I use the code like this:
QDir spumDir;
spumDir.setPath("Version/Temp");
spumProc->setWorkingDirectory(spumDir)
I get a memory referencing error.
And regarding using the cd command. If I use this command and change the path to Version/Temp then does it mean that now all my processes will get input and generate output from the changed path?
Thank you and sorry for replying and not generating a new thread- just tht that this was a related issue ...
RE: regarding Qprocess and working directory
Originally posted by GuestInTrouble
And regarding using the cd command. If I use this command and change the path to Version/Temp then does it mean that now all my processes will get input and generate output from the changed path?
If the process run by QProcess changes its path, only this process has a different path, not the parent or any other of its child processes.
Cheers,
_
Qt/KDE Developer
Debian User