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 974 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 31 Jan 2023, 12:35 last edited by
    #1

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

    J 1 Reply Last reply 31 Jan 2023, 12:47
    0
    • E Offline
      E Offline
      Emre MUTLU
      wrote on 31 Jan 2023, 12:44 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 1 Feb 2023, 06:59
      2
      • R Rumeysa_135
        31 Jan 2023, 12:35

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

        J Offline
        J Offline
        jsulm
        Lifetime Qt Champion
        wrote on 31 Jan 2023, 12:47 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 1 Feb 2023, 06:14
        2
        • J jsulm
          31 Jan 2023, 12:47

          @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 1 Feb 2023, 06:14 last edited by
          #4
          This post is deleted!
          J 1 Reply Last reply 1 Feb 2023, 07:11
          0
          • E Emre MUTLU
            31 Jan 2023, 12:44
            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 1 Feb 2023, 06:59 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
              1 Feb 2023, 06:14

              This post is deleted!

              J Offline
              J Offline
              jsulm
              Lifetime Qt Champion
              wrote on 1 Feb 2023, 07:11 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 1 Feb 2023, 08:58
              3
              • J jsulm
                1 Feb 2023, 07:11

                @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 1 Feb 2023, 08:58 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++.

                J 1 Reply Last reply 1 Feb 2023, 09:00
                0
                • R Rumeysa_135
                  1 Feb 2023, 08:58

                  @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++.

                  J Offline
                  J Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on 1 Feb 2023, 09:00 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

                  1/8

                  31 Jan 2023, 12:35

                  • Login

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