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. Wrong QProcess Behavior

Wrong QProcess Behavior

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 5 Posters 1.2k 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.
  • M Offline
    M Offline
    MrOplus
    wrote on last edited by MrOplus
    #1

    hi , i'm new to QT
    i have an application with runs some simple bash files .
    now when i run the application from the QTCreator everything works fine and i can read the QProcess output but when i open application directly i can't read the QProcess output and output is always "" .
    here is my code :

            QProcess proc ;
            proc.start(QCoreApplication::applicationDirPath() + "/check.sh");
            proc.waitForFinished();
            QString output = QString(proc.readAll());
            qDebug() << output ;
    

    i'm using QT 5.7 on OSX Platform
    note :
    *** when i run my application via terminal it works fine ***

    1 Reply Last reply
    0
    • K Offline
      K Offline
      karti gesar
      wrote on last edited by
      #2

      use readAllStandardOutput() to read the output

      m.sueM 1 Reply Last reply
      0
      • BharathiB Offline
        BharathiB Offline
        Bharathi
        wrote on last edited by
        #3

        Try
        /* proc.waitForFinished(-1);*/
        the above line wait untill the process gets finished.

        Refer this link
        http://doc.qt.io/qt-5/qprocess.html#waitForFinished

        1 Reply Last reply
        0
        • K karti gesar

          use readAllStandardOutput() to read the output

          m.sueM Offline
          m.sueM Offline
          m.sue
          wrote on last edited by
          #4

          @karti-gesar said in Wrong QProcess Behavior:

          use readAllStandardOutput() to read the output

          Hi,
          Yes, and use readAllStandardError()to get the error messages.
          Maybe the program did not run because of a wrong path.
          -Michael.

          1 Reply Last reply
          0
          • M Offline
            M Offline
            MrOplus
            wrote on last edited by
            #5

            ok when i run the application directly QCoreApplication::applicationDirPath() returns / as the dir but when i run the app via terminal it's the real application path !! is it a bug ?!

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Hi,

              How exactly are you calling your application ?
              Are you building an app bundle ?

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - 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