Question about QProcess
-
@RIVOPICO What exactly do you start using QProcess? If it is something like "cmd.exe ..." then you will get a console, but that's nothing related to Qt/QProcess - it's you starting a new console via QProcess.
And yes your explanation is really unclear - at least you should say what you're starting using QProcess. -
@RIVOPICO
QProcessjust fires the command and forgets. It wont remember the earlier state. So if youcdto previous directory in oneQProcessand then dolsin the nextQProcess, dont expect it to show contents from previous directory. It will always display the contents in same directory. -
@RIVOPICO
QProcessjust fires the command and forgets. It wont remember the earlier state. So if youcdto previous directory in oneQProcessand then dolsin the nextQProcess, dont expect it to show contents from previous directory. It will always display the contents in same directory. -
@RIVOPICO Are you trying to emulate
QDirthroughQProcess?
QDiralready contains cd .. and file listing is done through QDirIterator. -
@RIVOPICO Are you trying to emulate
QDirthroughQProcess?
QDiralready contains cd .. and file listing is done through QDirIterator. -
@RIVOPICO
QDirIteratoris 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 usingcdandlsandQProcess? Also what your application is supposed to do ? -
@RIVOPICO
QDirIteratoris 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 usingcdandlsandQProcess? Also what your application is supposed to do ? -
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
-
@p3c0 I am trying to simulate one terminal with simple application in qt for linux nothing more.
@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
QProcessis not the right way to do. May be you should try using some library like for eg. libvte.
Found this QML based term emulator. -
@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
QProcessis not the right way to do. May be you should try using some library like for eg. libvte.
Found this QML based term emulator. -
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
-
@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(); -
@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(); -
@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();