How do i parse string arrays in qt?
-
wrote on 31 Jan 2023, 12:35 last edited by
What can I do in qt to parse such a string array "0x02, 0x00, 0x19, 0x02, 0x1B, 0x03"?
-
wrote on 31 Jan 2023, 12:44 last edited by
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
-
What can I do in qt to parse such a string array "0x02, 0x00, 0x19, 0x02, 0x1B, 0x03"?
@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"...
-
@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"...
wrote on 1 Feb 2023, 06:14 last edited byThis post is deleted! -
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
wrote on 1 Feb 2023, 06:59 last edited by@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.
-
This post is deleted!
@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#toIntAnd please format your code properly.
-
@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#toIntAnd please format your code properly.
wrote on 1 Feb 2023, 08:58 last edited by@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#toIntAnd 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++. -
@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#toIntAnd 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++.@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.
1/8