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 to test with code readAllStandardError.isEmpty() is not empty ?
Forum Updated to NodeBB v4.3 + New Features

How to test with code readAllStandardError.isEmpty() is not empty ?

Scheduled Pinned Locked Moved Solved General and Desktop
4 Posts 2 Posters 310 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.
  • Q Offline
    Q Offline
    Qt embedded developer
    wrote on last edited by
    #1

    i want to test QProcess's readAllStandardError() return error . if possible please give me code that return error bytes.

    
                sError = qProcessSysCmd->readAllStandardError();
                if(!sError.isEmpty())
                {
                    AppLog::AddLog(LOG_ERROR, __FUNCTION__, __LINE__, sCommand + " sError:" + sError);
    #ifdef QDEBUG_ENABLE
                    pMainApp.ObjSettings.DebugStation(sCommand + " error : " + sError);
    #endif
                    bIsError = true;
                }
    
    raven-worxR 1 Reply Last reply
    0
    • Q Qt embedded developer

      @raven-worx said in How to test with code readAllStandardError.isEmpty() is not empty ?:

      myProc->readLine()

      when myProc->readLine() return zero value means error occured. am i right or not.

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #4

      @Qt-embedded-developer
      in my example this shouldn't be possible.
      So i guess your question is based on different usage?

      My example connects to the readyReadStandardError signal, which ensures that there is data available, further it checks if it can read a line before it finally reads the line.
      Thats the way to go if you want the stderr output during the execution of the process.
      Use readAllStandardError() on the other hand after the process has finished.

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      1 Reply Last reply
      3
      • Q Qt embedded developer

        i want to test QProcess's readAllStandardError() return error . if possible please give me code that return error bytes.

        
                    sError = qProcessSysCmd->readAllStandardError();
                    if(!sError.isEmpty())
                    {
                        AppLog::AddLog(LOG_ERROR, __FUNCTION__, __LINE__, sCommand + " sError:" + sError);
        #ifdef QDEBUG_ENABLE
                        pMainApp.ObjSettings.DebugStation(sCommand + " error : " + sError);
        #endif
                        bIsError = true;
                    }
        
        raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on last edited by raven-worx
        #2

        @Qt-embedded-developer
        For example:

        connect( myProc, &QProcess::readyReadStandardError, this, [myProc](){
                myProc.setReadChannel(QProcess::StandardError); // for stdout use QProcess::StandardOutput
                while( myProc.canReadLine() )
                    myProc->readLine() // line of stderr
            } );
        

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        Q 1 Reply Last reply
        1
        • raven-worxR raven-worx

          @Qt-embedded-developer
          For example:

          connect( myProc, &QProcess::readyReadStandardError, this, [myProc](){
                  myProc.setReadChannel(QProcess::StandardError); // for stdout use QProcess::StandardOutput
                  while( myProc.canReadLine() )
                      myProc->readLine() // line of stderr
              } );
          
          Q Offline
          Q Offline
          Qt embedded developer
          wrote on last edited by Qt embedded developer
          #3

          @raven-worx said in How to test with code readAllStandardError.isEmpty() is not empty ?:

          myProc->readLine()

          when myProc->readLine() return zero value means error occured. am i right or not.

          raven-worxR 1 Reply Last reply
          0
          • Q Qt embedded developer

            @raven-worx said in How to test with code readAllStandardError.isEmpty() is not empty ?:

            myProc->readLine()

            when myProc->readLine() return zero value means error occured. am i right or not.

            raven-worxR Offline
            raven-worxR Offline
            raven-worx
            Moderators
            wrote on last edited by
            #4

            @Qt-embedded-developer
            in my example this shouldn't be possible.
            So i guess your question is based on different usage?

            My example connects to the readyReadStandardError signal, which ensures that there is data available, further it checks if it can read a line before it finally reads the line.
            Thats the way to go if you want the stderr output during the execution of the process.
            Use readAllStandardError() on the other hand after the process has finished.

            --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
            If you have a question please use the forum so others can benefit from the solution in the future

            1 Reply Last reply
            3

            • Login

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