Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Using vector with QProcess
Qt 6.11 is out! See what's new in the release blog

Using vector with QProcess

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 3 Posters 1.3k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • RIVOPICOR Offline
    RIVOPICOR Offline
    RIVOPICO
    wrote on last edited by RIVOPICO
    #1

    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

    jsulmJ 1 Reply Last reply
    0
    • T Offline
      T Offline
      TheGringerEye
      wrote on last edited by
      #2

      Using QVector, He is std::vector+ support MOC.

      I try to learn English.

      1 Reply Last reply
      0
      • RIVOPICOR RIVOPICO

        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

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #3

        @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");
        }
        

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved