Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QtWebEngine
  4. How do i parse string arrays in qt?
Forum Updated to NodeBB v4.3 + New Features

How do i parse string arrays in qt?

Scheduled Pinned Locked Moved Solved QtWebEngine
8 Posts 3 Posters 978 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.
  • R Offline
    R Offline
    Rumeysa_135
    wrote on last edited by
    #1

    What can I do in qt to parse such a string array "0x02, 0x00, 0x19, 0x02, 0x1B, 0x03"?

    jsulmJ 1 Reply Last reply
    0
    • E Offline
      E Offline
      Emre MUTLU
      wrote on last edited by
      #2
      QString str="0x02,0x00,0x19,0x02,0x1b,0x03";
      QStringList list;
      foreach(const QString str1,str.split(",")) {
      list+=str1;
      }
      qDebug()<<list;
      

      and you can access this values in list.takeAt(int i) function

      R 1 Reply Last reply
      2
      • R Rumeysa_135

        What can I do in qt to parse such a string array "0x02, 0x00, 0x19, 0x02, 0x1B, 0x03"?

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

        @Rumeysa_135 said in How do i parse string arrays in qt?:

        What can I do in qt to parse such a string array

        Depends on what you mean by "parse"...

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

        R 1 Reply Last reply
        2
        • jsulmJ jsulm

          @Rumeysa_135 said in How do i parse string arrays in qt?:

          What can I do in qt to parse such a string array

          Depends on what you mean by "parse"...

          R Offline
          R Offline
          Rumeysa_135
          wrote on last edited by
          #4
          This post is deleted!
          jsulmJ 1 Reply Last reply
          0
          • E Emre MUTLU
            QString str="0x02,0x00,0x19,0x02,0x1b,0x03";
            QStringList list;
            foreach(const QString str1,str.split(",")) {
            list+=str1;
            }
            qDebug()<<list;
            

            and you can access this values in list.takeAt(int i) function

            R Offline
            R Offline
            Rumeysa_135
            wrote on last edited by
            #5

            @Emre-MUTLU said in How do i parse string arrays in qt?:

            QString str="0x02,0x00,0x19,0x02,0x1b,0x03";
            QStringList list;
            foreach(const QString str1,str.split(",")) {
            list+=str1;
            }
            qDebug()<<list;
            

            and you can access this values in list.takeAt(int i) function

            Thank you for answer. I will try.

            1 Reply Last reply
            0
            • R Rumeysa_135

              This post is deleted!

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

              @Rumeysa_135 said in How do i parse string arrays in qt?:

              for(i=1;i<count-1;i++)
              {
              calcArray[i-1];
              }

              What is this supposed to do? calcArray[i-1] does nothing.
              I also don't know what this code has to do with Qt?
              If you're asking how to convert a QString containing hex numbers to an array containing integer numbers then please check the code from @Emre-MUTLU and also https://doc.qt.io/qt-6/qstring.html#toInt

              And please format your code properly.

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

              R 1 Reply Last reply
              3
              • jsulmJ jsulm

                @Rumeysa_135 said in How do i parse string arrays in qt?:

                for(i=1;i<count-1;i++)
                {
                calcArray[i-1];
                }

                What is this supposed to do? calcArray[i-1] does nothing.
                I also don't know what this code has to do with Qt?
                If you're asking how to convert a QString containing hex numbers to an array containing integer numbers then please check the code from @Emre-MUTLU and also https://doc.qt.io/qt-6/qstring.html#toInt

                And please format your code properly.

                R Offline
                R Offline
                Rumeysa_135
                wrote on last edited by
                #7

                @jsulm said in How do i parse string arrays in qt?:

                @Rumeysa_135 said in How do i parse string arrays in qt?:

                for(i=1;i<count-1;i++)
                {
                calcArray[i-1];
                }

                What is this supposed to do? calcArray[i-1] does nothing.
                I also don't know what this code has to do with Qt?
                If you're asking how to convert a QString containing hex numbers to an array containing integer numbers then please check the code from @Emre-MUTLU and also https://doc.qt.io/qt-6/qstring.html#toInt

                And please format your code properly.

                Actually, what I'm trying to explain is to try to parse the hexadecimal data from another source.
                Incoming data should start with 0x02 and end with 0x03 so I tried to write a code like this. You're right about calcArray, I didn't realize. I created my code in my head and wrote it in notepad++.

                jsulmJ 1 Reply Last reply
                0
                • R Rumeysa_135

                  @jsulm said in How do i parse string arrays in qt?:

                  @Rumeysa_135 said in How do i parse string arrays in qt?:

                  for(i=1;i<count-1;i++)
                  {
                  calcArray[i-1];
                  }

                  What is this supposed to do? calcArray[i-1] does nothing.
                  I also don't know what this code has to do with Qt?
                  If you're asking how to convert a QString containing hex numbers to an array containing integer numbers then please check the code from @Emre-MUTLU and also https://doc.qt.io/qt-6/qstring.html#toInt

                  And please format your code properly.

                  Actually, what I'm trying to explain is to try to parse the hexadecimal data from another source.
                  Incoming data should start with 0x02 and end with 0x03 so I tried to write a code like this. You're right about calcArray, I didn't realize. I created my code in my head and wrote it in notepad++.

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

                  @Rumeysa_135 I gave you a link to a method to convert a hex string to an integer and @Emre-MUTLU gave you code to split a string into hex numbers. You should now be good to go and write what you need. If something is not clear then please ask concrete questions and provide more details.

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

                  1 Reply Last reply
                  2

                  • Login

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