Unsolved Question about QProcess
-
@RIVOPICO Are you trying to emulate
QDir
throughQProcess
?
QDir
already contains cd .. and file listing is done through QDirIterator. -
@p3c0 said in Question about QProcess:
QDirIterator.
i tried too but qprocess show me all time the same path.
-
@RIVOPICO
QDirIterator
is not a process so cant be used withQProcess
. I was just suggesting an alternate way for what I imagined you are trying to do.
Can you explain again what you are trying to do usingcd
andls
andQProcess
? Also what your application is supposed to do ? -
@p3c0 I am trying to simulate one terminal with simple application in qt for linux nothing more.
-
If I'm not mistaken you just need to start the terminal with QProcess and then use QProcess::write to send the commands. see the gzip example in http://doc.qt.io/qt-5/qprocess.html
-
@RIVOPICO said in Question about QProcess:
@p3c0 I am trying to simulate one terminal with simple application in qt for linux nothing more.
Then IMO
QProcess
is not the right way to do. May be you should try using some library like for eg. libvte.
Found this QML based term emulator. -
@p3c0 setWorkingDirectory i can change the path. But i think will not be remembered..
-
@VRonin you say send the commands but for example if i change the path will be remembered?
-
@RIVOPICO you can record the path by yourself, stack or vector sounds like a good data structure for this purpose(stack is an adapter in stl, either vector,deque or list work for std::stack).
Following is the idea of how to store the path you iterate, please handle the errors and convert it to nice,
reuse able function by yourself.//store the paths you iterate std::vector<QString> paths; paths.emplace_back("first path"); paths.emplace_back("second path"); if(input_path == "cd"){ QDir new_path(paths.back()); new_path.cd(); paths.emplace_back(new_path.absolutePath()); } //back to previous path, stl split back and pop_back to two actions for the sake of exception safe auto const path = paths.back(); paths.pop_back();
-
This post is deleted! -
@tham you are right it's nice idea