Solved How do i parse string arrays in qt?
-
What can I do in qt to parse such a string array "0x02, 0x00, 0x19, 0x02, 0x1B, 0x03"?
-
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
-
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
-
@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"...
-
This post is deleted! -
@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.
-
@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.
-
@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.