I wrote some code that tries to extract an integer 100 out of this string:
"AB,SH#100 \r\n\0"
but the toInt() always fails; i.e. 0 is returned from toInt(). Note that the original data came in from QByteArray(). I currently use append() to convert from QByteArray to QString.
As a separate question, is there a better way to convert QByteArray to QString than QString::append()?
test.append( bte );
tmp[0].remove( 0, 3 );
int value = test.toInt();
QByteArray bte = "AB,SH#100 \r\n\0";
QString test;
test.append( bte );
QStringList list = test.split( "," );
QStringList tmp = list.filter( "SH#" );
tmp[0].remove( 0, 3 );
int value = test.toInt();
To copy to clipboard, switch view to plain text mode
Thanks!
Bookmarks