Solved Using vector with QProcess
-
Hi i am using QProces but everyone know that the path never is recorded. And like i'm learning about vector's i am trying to do one example with this.
I was thinking to use this:
First i put the path so with this new_path.cd(path); i change the path and with the follow code i return back with
auto const path = paths.back();
paths.pop_back();Or i change the path with cd Path so what do you think good idea?
Code:
//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();
It's for learning more about vector's
-
Using QVector, He is std::vector+ support MOC.
-
@RIVOPICO Not sure I understand your question. How is it related to QProcess?
You could do:std::vector<QString> paths; paths.emplace_back("first path"); if(input_path == "cd"){ QDir new_path("second path"); new_path.cd(); paths.emplace_back(new_path.absolutePath()); } else { paths.emplace_back("second path"); }