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. [Solved] How to compare data read from process->readAllStandardOutput() with a string
Forum Updated to NodeBB v4.3 + New Features

[Solved] How to compare data read from process->readAllStandardOutput() with a string

Scheduled Pinned Locked Moved General and Desktop
12 Posts 3 Posters 3.4k 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.
  • S Offline
    S Offline
    Swinetha
    wrote on 29 Aug 2013, 04:29 last edited by
    #1

    hai,

    I am reading the data from process->readAllStandardOutput() to a QByteArray.in my application I want to compare data read from process with one string, depends upon the string only I will do further step.

    I did as below but it's not working

    @QByteArray b1=process->readAllStandardOutput() ;
    char* text="Unable to read data";
    if(strcmp(b1.data(),text)==0)
    ui1->THI_Data->setText(text);@

    but it does not enter into if condition.

    how can I compare the data

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 29 Aug 2013, 07:38 last edited by
      #2

      Hi,

      You should rather use QString. It has all the function needed for what you want

      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
      • S Offline
        S Offline
        Swinetha
        wrote on 29 Aug 2013, 08:23 last edited by
        #3

        even for QString also it's not enter to if condition I am already tested

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 29 Aug 2013, 09:57 last edited by
          #4

          Did you simply check/print the content of b1 ? You might have more data than you think.

          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
          • S Offline
            S Offline
            Swinetha
            wrote on 29 Aug 2013, 11:10 last edited by
            #5

            it is also completed.

            compared data n read data both are same
            even it is not come into if condition

            1 Reply Last reply
            0
            • S Offline
              S Offline
              SGaist
              Lifetime Qt Champion
              wrote on 29 Aug 2013, 20:02 last edited by
              #6

              if the condition fails it means they are not the same. Maybe a control char like \n that you did not see.

              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
              • S Offline
                S Offline
                Swinetha
                wrote on 30 Aug 2013, 04:19 last edited by
                #7

                hi
                what ever I written in the C-Code the same thing is written in GUI even also if() condition is not satisfied.

                Can I add anything more to that string.....

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on 30 Aug 2013, 09:03 last edited by
                  #8

                  Can you post the exact content of b1 ?
                  And the code using QString for the comparison ?

                  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
                  • D Offline
                    D Offline
                    dbzhang800
                    wrote on 30 Aug 2013, 09:21 last edited by
                    #9

                    please given the result of

                    qDebug()<<b1.toHex();

                    and

                    qDebug()<<QByteArray(text).toHex();

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      Swinetha
                      wrote on 10 Sept 2013, 11:12 last edited by
                      #10

                      sorry for the late reply and thanks for your valuable suggetions I found the solution for this

                      1 Reply Last reply
                      0
                      • S Offline
                        S Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on 10 Sept 2013, 20:14 last edited by
                        #11

                        Could you share the solution ?

                        Since you got it working, please update the thread title prepending [solved] so other forum users may know that it is working now :)

                        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
                        • S Offline
                          S Offline
                          Swinetha
                          wrote on 11 Sept 2013, 04:07 last edited by
                          #12

                          I am comparing the hexadecimal data directly so it is working.

                          like if(b1.toHex()==QByteArray(text).toHex())

                          it is working.

                          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