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. How Can I Run QProcess on Linux?

How Can I Run QProcess on Linux?

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 3 Posters 564 Views 1 Watching
  • 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.
  • HerrWinfriedH Offline
    HerrWinfriedH Offline
    HerrWinfried
    wrote on last edited by
    #1

    I wrote a command like below, but it doesn't work, I think I did it wrong and there were points I missed. The command doesn't work at all. The output is right below.

    QProcess process;
            QString commandq = "-c ";
            commandq = commandq + "echo 'hello' >> /home/winfried/text.txt;";
            process.start("bash", QStringList() << commandq);
    

    Output:

    QProcess: Destroyed while process ("bash") is still running.
    
    M JonBJ 2 Replies Last reply
    0
    • HerrWinfriedH HerrWinfried

      I wrote a command like below, but it doesn't work, I think I did it wrong and there were points I missed. The command doesn't work at all. The output is right below.

      QProcess process;
              QString commandq = "-c ";
              commandq = commandq + "echo 'hello' >> /home/winfried/text.txt;";
              process.start("bash", QStringList() << commandq);
      

      Output:

      QProcess: Destroyed while process ("bash") is still running.
      
      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #3

      @HerrWinfried
      Your QProcess process; variable goes out of scope while the process has been started but not yet finished.

      For now, just put a process.waitForFinished() immediately after the process.start(). Later do it with signals and slots, but bear the lifetime scope in mind.

      Your command arguments are wrong. You will need:

      process.start("bash", QStringList() << "-c" << "echo 'hello' >> /home/winfried/text.txt;");
      
      1 Reply Last reply
      4
      • HerrWinfriedH HerrWinfried

        I wrote a command like below, but it doesn't work, I think I did it wrong and there were points I missed. The command doesn't work at all. The output is right below.

        QProcess process;
                QString commandq = "-c ";
                commandq = commandq + "echo 'hello' >> /home/winfried/text.txt;";
                process.start("bash", QStringList() << commandq);
        

        Output:

        QProcess: Destroyed while process ("bash") is still running.
        
        M Offline
        M Offline
        mpergand
        wrote on last edited by
        #2

        @HerrWinfried said in How Can I Run QProcess on Linux?:
        `

        QProcess: Destroyed while process ("bash") is still running.

        The message is explicit, you declare QProccess as local variable so it is destroyed at the end of the method where it is.

        Adding process.waitForFinished after process.start should work.

        1 Reply Last reply
        3
        • HerrWinfriedH HerrWinfried

          I wrote a command like below, but it doesn't work, I think I did it wrong and there were points I missed. The command doesn't work at all. The output is right below.

          QProcess process;
                  QString commandq = "-c ";
                  commandq = commandq + "echo 'hello' >> /home/winfried/text.txt;";
                  process.start("bash", QStringList() << commandq);
          

          Output:

          QProcess: Destroyed while process ("bash") is still running.
          
          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by JonB
          #3

          @HerrWinfried
          Your QProcess process; variable goes out of scope while the process has been started but not yet finished.

          For now, just put a process.waitForFinished() immediately after the process.start(). Later do it with signals and slots, but bear the lifetime scope in mind.

          Your command arguments are wrong. You will need:

          process.start("bash", QStringList() << "-c" << "echo 'hello' >> /home/winfried/text.txt;");
          
          1 Reply Last reply
          4

          • Login

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